Current .Net Version: 1.1.4322
Home
Articles
Practice C# Online
C# Reference
XML Web Services
RSS Feeds
T-SQL Scripts
Valuable Links
Contact Us
C# Reference
List: Search:

expression
Is a:Definition
Applies to Version:C# 1.0 and later
Namespace:N/A
Assembly:N/A (N/A)
Description:An expression is any block of code that can return an object value. Typically, an expression returns a boolean value (as in an if-else statement). The value derived from an expression must be evaluated. In other words, you can't place a block of code inside of surrounding parenthesis all by itself - you'll get an error if you do.
Example(s):if (true) // returns a bool value MessageBox.Show("It's TRUE!"); // this is executed else MessageBox.Show("It's FALSE!"); MessageBox.Show((1 == 1).ToString()); // this will print "True"; MessageBox.Show((1 != 1).ToString()); // this will print "False"; int i = 1; switch (i) // returns an int value { case 1: MessageBox.Show("It's 1."); break; case 2: MessageBox.Show("It's 2."); break; } bool bln = true; String s = ("Hello " + bln.ToString() + " World!").ToUpper(); // returns a string value MessageBox.Show(s); // prints "HELLO TRUE WORLD!";
 
COPYRIGHT/DISCLAIMER | CONTACT US