Chapter 5: Getting into the Program Flow

In This Chapter

check.png Making decisions if you can

check.png Deciding what else to do

check.png Looping without going in a circle

check.png Using the while and do . . . while loops

check.png Using the for loop and understanding scope

Consider this simple program:

using System;

namespace HelloWorld

{

  public class Program

  {

    // This is where the program starts.

    static void Main(string[] args)

    {

      // Prompt user to enter a name.

      Console.WriteLine(“Enter your name, please:”);

      // Now read the name entered.

      string name = Console.ReadLine();

      // Greet the user with the entered name.

      Console.WriteLine(“Hello, “ + name);

      // Wait for user to acknowledge the results.

      Console.WriteLine(“Press Enter to terminate . . . “);

      Console.Read();

    }

  }

}

Beyond introducing you to a few fundamentals of C# programming, this program is almost worthless. It simply spits back out whatever you entered. You can imagine more complicated program examples ...

Get C# 5.0 All-in-One For Dummies 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.