Creating Expressions and Statements

It's now time to start actually doing something with the data discussed so far. The first essential topic in C# coding is the expression. An expression can be evaluated and it yields a single value. At the most basic, literals are expressions, because they evaluate to a value. Variables are also expressions, because they evaluate to the value they contain.

Here's another expression—5 + 3—which evaluates to 8. In fact, int1 = 1, where you assign 1 to the variable int1, is an expression, and its value is 1. Because int1 = 1 is an expression yielding 1, it's legal in C# to create expressions like this: int3 = int2 = int1 = 1. We'll be using the term expression frequently throughout this book, and the thing to ...

Get Microsoft® Visual C#® .NET 2003 Kick Start 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.