Thursday, 14 April 2016

C# For Beginners Lesson 28 - Decision Making and Relational Operators

The relational operators compare values to one other. The comparison operators are =<><><=, and >=. All of the relational operators result in aBoolean value.
The relational operators have the following general meaning:
  • The = operator tests whether the two operands are equal.
  • The <> operator tests whether the two operands are not equal.
  • The < operator tests whether the first operand is less than the second operand.
  • The > operator tests whether the first operand is greater than the second operand.
  • The <= operator tests whether the first operand is less than or equal to the second operand.
  • The >= operator tests whether the first operand is greater than or equal to the second operand.
The relational operators are defined for the following types:
  • Boolean. The operators compare the truth values of the two operands. True is considered to be less than False, which matches with their numeric values.
  • ByteShortInteger, and Long. The operators compare the numeric values of the two integral operands.
  • Single and Double. The operators compare the operands according to the rules of the IEEE 754 standard.
  • Decimal. The operators compare the numeric values of the two decimal operands.
  • Date. The operators return the result of comparing the two date/time values.
  • Char. The operators return the result of comparing the two Unicode values.
  • String. The operators return the result of comparing the two values using either a binary comparison or a text comparison. The comparison used is determined by the compilation environment and the Option Compare statement. A binary comparison determines whether the numeric Unicode value of each character in each string is the same. A text comparison does a Unicode text comparison based on the current culture in use on the .NET Framework. When doing a string comparison, a null reference is equivalent to the string literal "".
RelationalOperatorExpression ::=
   Expression = Expression |
   Expression < > Expression |
   Expression < Expression |
   Expression > Expression |
   Expression < = Expression |
   Expression > = Expression

No comments:

Post a Comment