Expressions

Expressions are statements that, when executed, result in a value. When programming, you use expressions all the time, sometimes without even realizing it. The following are examples of expressions:

VB

65 + 5 ' Produces a value of 70. 
( i < 10 ) ' Produces a true or false. 

C#

5 * 100 // Produces a value of 500 
x = 25 - 5 // Subtracts 5 from 25 then stores in x 

JScript

175 - 4 // Produces 171 
15 / 3 // Produces 5 

Expressions typically are composed of several smaller expressions, or subexpressions, connected by operators. For instance, consider the following lines of C# code:

int x = 100, y; 
y = ( x / 4 ) + 3; 

The first line of code, where the variables are declared, actually contains an expression in the assignment of 100 ...

Get Special Edition Using® Microsoft® ASP.NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.