Example of using logical operators for a truth table.
bool x = true;
bool y = true;
Console.WriteLine("-------------------------------");
Console.WriteLine("Values: x = " + x + " | y = " + y);
Console.WriteLine("-------------------------------");
Console.WriteLine("!x = " + !x); // False
Console.WriteLine("x && y = " + (x && y)); // True
Console.WriteLine("x || y = " + (x || y)); // True
Console.WriteLine("x ^ y = " + (x ^ y)); // False
Console.WriteLine();
x = true;
y = false;
Console.WriteLine("-------------------------------");
Console.WriteLine("Values: x = " + x + " | y = " + y);
Console.WriteLine("-------------------------------");
Console.WriteLine("!x = " + !x); // False
Console.WriteLine("x && y = " + (x && y)); // False
Console.WriteLine("x || y = " + (x || y)); // True
Console.WriteLine("x ^ y = " + (x ^ y)); // True
Console.WriteLine();
x = false;
y = true;
Console.WriteLine("-------------------------------");
Console.WriteLine("Values: x = " + x + " | y = " + y);
Console.WriteLine("-------------------------------");
Console.WriteLine("!x = " + !x); // True
Console.WriteLine("x && y = " + (x && y)); // False
Console.WriteLine("x || y = " + (x || y)); // True
Console.WriteLine("x ^ y = " + (x ^ y)); // True
Console.WriteLine();
x = false;
y = false;
Console.WriteLine("-------------------------------");
Console.WriteLine("Values: x = " + x + " | y = " + y);
Console.WriteLine("-------------------------------");
Console.WriteLine("!x = " + !x); // True
Console.WriteLine("x && y = " + (x && y)); // False
Console.WriteLine("x || y = " + (x || y)); // False
Console.WriteLine("x ^ y = " + (x ^ y)); // False