DekGenius.com
Team LiB   Previous Section   Next Section

Chapter 7. Operators

An operator is a symbol (e.g., =, +, >, etc.) that causes C# to take an action. That action might be an assignment of a value to a variable, the addition of two values, or a comparison of two values, etc.

In the previous chapters, you've seen a number of operators at work. For example, in Chapter 5 you saw the assignment operator used. The single equal sign (=) is used to assign a value to a variable, in this case the value 15 to the variable myVariable:

myVariable = 15;

In Chapter 6 you saw more sophisticated operators, such as the greater-than comparison operator (>) used to compare two values:

if ( valueOne > valueTwo )

The preceding if statement compares valueOne with valueTwo; if the former is larger than the latter, the test evaluates true, and the if statement executes.

This chapter describes many of the operators used in C# in some detail.

    Team LiB   Previous Section   Next Section