Export (0) Print
Expand All
1 out of 3 rated this helpful - Rate this topic

7.9.7 String equality operators

Visual Studio .NET 2003

The predefined string equality operators are:

bool operator ==(string x, string y);
bool operator !=(string x, string y);

Two string values are considered equal when one of the following is true:

  • Both values are null.
  • Both values are non-null references to string instances that have identical lengths and identical characters in each character position.

The string equality operators compare string values rather than string references. When two separate string instances contain the exact same sequence of characters, the values of the strings are equal, but the references are different. As described in Section 7.9.6, the reference type equality operators can be used to compare string references instead of string values.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.