Boolean keyword in c#

Boolean keyword in c#

In this article, bool type keyword, The bool type keyword is an alias for the .NET System.Boolean structure type that represents a Boolean value, which can be either true or false.

bool check = true;
Console.WriteLine(false ? "Checked" : "Not checked");  // output: Not checked
Console.WriteLine(check ? "Checked" : "Not checked");  // output: Checked

using System; 
  
class usingcsharp{
    public static void Main() 
    { 
   
        check(true, true); 
        check(true, false); 
        check(false, true); 
        check(false, false); 
    }   
    // Defining check method 
    public static void check(bool input1, bool input2) 
    {   
        // declaring bool variable 
        bool val;   
        // getting parsed value 
        val = input1.Equals(input2); 
  
        // cheking the equivalency 
        if (val == true) 
            Console.WriteLine("{0} is equal to {1}", 
                                    input1, input2); 
  
        else
            Console.WriteLine("{0} is not equal to {1}", 
                                        input1, input2); 
    } 
}

2021-10-03