Logical Operators C# with Example
using System; namespace CSharpFundamentals { class LogicalOperators { private static void Main(string[] args) { Console.WriteLine("Logical & (AND) Operator"); Console.WriteLine("true & true : {0}", true & true); Console.WriteLine("true & false : {0}", true & false); Console.WriteLine("false & true : {0}", false & true); Console.WriteLine("false & false : {0}\n", false & false); Console.WriteLine("Logical && (Short-Circuit AND) Operator"); Console.WriteLine("true && true : {0}", true && true); Console.WriteLine("true && false : {0}", true && false); Console.WriteLine("false && true : {0}", false && true); Console.WriteLine("false && false : {0}\n", false && false); Console.WriteLine("Logical | (OR) Operator"); Console.WriteLine("true | true : {0}", true | true); Console.WriteLine("true | false : {0}", true | false); Console.WriteLine("false | true : {0}", false | true); Console.WriteLine("false | false : {0}\n", false | false); Console.WriteLine("Logical || (Short-Circuit OR) Operator"); Console.WriteLine("true || true : {0}", true || true); Console.WriteLine("true || false : {0}", true || false); Console.WriteLine("false || true : {0}", false || true); Console.WriteLine("false || false : {0}\n", false || false); Console.WriteLine("Logical ^ (XOR) Operator"); Console.WriteLine("true ^ true : {0}", true ^ true); Console.WriteLine("true ^ false : {0}", true ^ false); Console.WriteLine("false ^ true : {0}", false ^ true); Console.WriteLine("false ^ false : {0}\n", false ^ false); Console.WriteLine("Logical ! (NOT) Operator"); Console.WriteLine("!true : {0}", !true); Console.WriteLine("!false : {0}\n", !false); } } }