<= Operator (C# Reference)

The "less than or equal" relational operator <= returns true if its first operand is less than or equal to its second operand, false otherwise. All numeric and enumeration types support the <= operator. For operands of the same enum type, the corresponding values of the underlying integral type are compared.


For relational operators ==, >, <, >=, and <=, if any of the operands is not a number (Double.NaN or Single.NaN) the result of operation is false. That means that the NaN value is neither greater than, less than, nor equal to any other double (or float) value. For more information and examples, see the Double.NaN or Single.NaN reference article.

The following example demonstrates the usage of the <= operator:

Console.WriteLine(7.0 <= 5.1);   // output: False
Console.WriteLine(5.1 <= 5.1);   // output: True
Console.WriteLine(0.0 <= 5.1);   // output: True

Console.WriteLine(double.NaN > 5.1);   // output: False
Console.WriteLine(double.NaN <= 5.1);  // output: False

Operator overloadability

User-defined types can overload the <= operator. If a type overloads the "less than or equal" operator <=, it must also overload the "greater than or equal" operator >=.

C# language specification

For more information, see the Relational and type-testing operators section of the C# language specification.

See also