Comparing Equalities

Comparing values, particularly variables, is even more common than performing arithmetic (but you need to know how Visual C# .NET arithmetic works before you can understand the evaluation of equalities).

Comparison operators are most often used in decision-making structures, as explained in the next hour. Indeed, these operators are best understood using a simple if decision structure. In an if construct, Visual C# .NET considers the expression in the if statement, and if the expression equates to true, the code statement(s) are executed. For example, the following is an if operation (a silly one at that) expressed in English, not in Visual C# .NET code:

IF DOGS BARK, THEN SMILE.

If this were in Visual C# .NET code format, ...

Get Sams Teach Yourself Microsoft® Visual C#™ .NET in 24 Hours 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.