less than or equal to c# code example

Example 1: c# is not equal to

// != returns true only if its operands are not equal.
// Otherwise it returns false.

// Here is an example:

int a = 1;
int b = 2;

if (a == b) {
  Console.WriteLine("A and b have the same value stored in them!");
else if (a != b) {
  Console.WriteLine("A and b do not have the same value stored in them!");
}

// Running this script should give you this in the console:
// A and b do not have the same value stored in them!
  
// !!! UNITY USER READ THIS !!! UNITY USER READ THIS !!!
  
// If you are using Unity game engine then you should
// use Debug.Log() instead of Console.WriteLine() to write
// something to the console.
  
// Hopefully this helped you out!

Example 2: c# switch case greater than

int mark = 50;
switch (mark)
{
    case int n when n >= 80:
        Console.WriteLine("Grade is A");
        break;

    case int n when n >= 60:
        Console.WriteLine("Grade is B");
        break;

    case int n when n >= 40:
        Console.WriteLine("Grade is C");
        break;

    default:
        Console.WriteLine("Grade is D");
        break;
}

Tags: