not operator in c# code example

Example 1: c# or

// The or statement in C# is ||
if (a == b || a == c)
{
  // Do something
}

Example 2: c# not

//the not operator of c sharp is "!" you can basicly revers a if statement!
if(a != 0)
{
  //if a is not equals to 0
}

Example 3: or c#

float numberOne = 1;
string stringOne = "one";

if (numberOne == 1 || stringOne == "one") 
  {
  print("numberOne or stringOne = 1")
  }

Example 4: || in c#

bool SecondOperand()
{
    Console.WriteLine("Second operand is evaluated.");
    return true;
}

bool a = true || SecondOperand();
Console.WriteLine(a);
// Output:
// True

bool b = false || SecondOperand();
Console.WriteLine(b);
// Output:
// Second operand is evaluated.
// True