settingsAccountsettings
By using our mini forum, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy
Menusettings

Q: How to check in C# whether a particular number is bigger than another number?

+5 votes

How to check in C# whether a particular number is bigger than another number?

For example whether 1 is bigger than 2.

asked in C# category by user Jolie Ann

1 Answer

+3 votes
 
Best answer

Use the Boolean data type


The Boolean data type is a data type, having two values (usually denoted true and false), intended to represent the truth values of logic and Boolean algebra.

It is named after George Boole, who first defined an algebraic system of logic in the mid 19th century.


In C# the code will look like this:

using System;

class CheckWhosBigger
{
    static void Main()
    {
        int a = 1;
        int b = 2;
        bool Check = (a > b); // False
        Console.WriteLine(Check);
    }
}

 

answered by user andrew
edited by user golearnweb
...