Demonstrate bool values : bool « Data Types « C# / C Sharp






Demonstrate bool values

Demonstrate bool values
   
/*
C#: The Complete Reference 
by Herbert Schildt 

Publisher: Osborne/McGraw-Hill (March 8, 2002)
ISBN: 0072134852
*/
// Demonstrate bool values. 
 
using System; 
 
public class BoolDemo { 
  public static void Main() { 
    bool b; 
 
    b = false; 
    Console.WriteLine("b is " + b); 
    b = true; 
    Console.WriteLine("b is " + b); 
 
    // a bool value can control the if statement 
    if(b) Console.WriteLine("This is executed."); 
 
    b = false; 
    if(b) Console.WriteLine("This is not executed."); 
 
    // outcome of a relational operator is a bool value 
    Console.WriteLine("10 > 9 is " + (10 > 9)); 
  } 
}

           
         
    
    
  








Related examples in the same category

1.bool variable
2.A static method that returns a Boolean value.
3.Using BoolUsing Bool
4.Print a truth table for the logical operatorsPrint a truth table for the logical operators
5.bool FalseString, TrueString
6.Convert boolean value to "Yes" or "No"
7.Converts string to Boolean, throws an exception if not compatible
8.Convert string to Boolean. A return value indicates whether the conversion succeeded or failed.
9.Convert text values to boolean