O'Reilly logo

Microsoft®C# Programming for the absolute beginner by Andy Harris

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

Creating a Branch in Program Logic

One reason computer programs are interesting is that they can appear to change behavior. The key to this flexibility is the condition structure. Before I launch into a definition of the condition structure, take a look at the Hi Bill game.

The Hi Bill Game

To illustrate the point of conditions–and their cousin, the if statement–I wrote a program that checks whether the user is Bill Gates. (I’m sure that Bill is hanging out at the bookstore as I write this, eagerly waiting to buy this book.) Just in case, I’ll be ready. Here’s the source code for the Hi Bill program:

 using System; namespace AreYouBill { /// <summary> /// Demonstrates the If Statement /// </summary> class AreYouBill { static void Main(string[] args) ...

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