That is, two record operands are equal when both of them are null or corresponding values of all fields and auto-implemented properties are equal. Record types equalityĪvailable in C# 9.0 and later, record types support the = and != operators that by default provide value equality semantics. If a reference type overloads the = operator, use the Object.ReferenceEquals method to check if two references of that type refer to the same object. However, a reference type can overload the = operator. Reference types equalityīy default, two non-record reference-type operands are equal if they refer to the same object: public class ReferenceTypesEqualityĬonsole.WriteLine(a = b) // output: FalseĬonsole.WriteLine(a = c) // output: TrueĪs the example shows, user-defined reference types support the = operator by default. For more information, see the Tuple equality section of the Tuple types article. To support the = operator, a user-defined struct must overload it.īeginning with C# 7.3, the = and != operators are supported by C# tuples. User-defined struct types don't support the = operator by default. Two operands of the same enum type are equal if the corresponding values of the underlying integral type are equal. For more information and examples, see the Double.NaN or Single.NaN reference article.
![symbol for does not equal symbol for does not equal](https://dailyverses.net/images/en/niv/xl/romans-2-1-2.jpg)
That means that the NaN value is neither greater than, less than, nor equal to any other double (or float) value, including NaN.
![symbol for does not equal symbol for does not equal](https://www.freecodecamp.org/news/content/images/2021/07/WhatsApp-Image-2021-07-28-at-10.52.19.jpeg)
![symbol for does not equal symbol for does not equal](https://www.pinclipart.com/picdir/middle/159-1597948_greater-than-and-single-line-not-equal-to.png)
For the =,, = operators, if any of the operands is not a number ( Double.NaN or Single.NaN), the result of operation is false.