The Boolean Type in C Sharp

by Dinesh 2012-07-22 20:15:59

The Boolean Type in C#

Boolean types are declared using the keyword, bool. They have two values: true or false. In other languages, such as C and C++, boolean conditions can be satisfied where 0 means false and anything else means true. However, in C# the only values that satisfy a boolean condition is true and false, which are official keywords.

Displaying Boolean Values: Boolean.cs

using System;

class Booleans
{
public static void Main()
{
bool content = true;
bool noContent = false;

Console.WriteLine("It is {0} that C# Station provides C# programming language content.", content);
Console.WriteLine("The statement above is not {0}.", noContent);
}
}

The boolean values are written to the console as a part of a sentence. The only legal values for the bool type are either true or false, as shown by the assignment of true to content and false to noContent. When run, this program produces the following output:

It is True that C# Station provides C# programming language content.
The statement above is not False.

Tagged in:

781
like
0
dislike
0
mail
flag

You must LOGIN to add comments