O'Reilly logo

A Programmer's Guide to C# 5.0, 4th Edition by Nick Wienholt, Eric Gunnerson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 11

image

Statements and Flow of Execution

The following sections detail the different statements that are available within the C# language.

Selection Statements

The selection statements are used to perform operations based on the value of an expression.

If

The if statement in C# requires that the condition inside the if statement evaluate to an expression of type bool. In other words, the following is illegal:1

// errorusing System;class Test{    public static void Main()    {       int value = 0;       if (value)       // invalid       {            System.Console.WriteLine("true");       }       if (value == 0)    // must use this        ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required