#21 – Boolean Literals

A boolean literal is represented by one of two keywords–either true or false.  A boolean literal is always of type bool.

Here are a few examples:

 bool happy = true;
 bool rich = false;
 if (happy == true) Console.WriteLine("Happy guy");
 File.Copy(@"C:\From.txt", @"C:\To.txt", false);  // don't overwrite
 while (true) Console.WriteLine("Loop forever");

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: