In riferimento al mio post precedente, vediamo cosa dicono gli standard:
Java Language Specification, 2nd edition |
Standard ECMA-334. C# Language Specification, 2nd edition |
15.21.3 While == may be used to compare references of type String, such an equality test determines whether or not the two operands refer to the same String object. The result is false if the operands are distinct String objects, even if they contain the same sequence of characters. The contents of two strings s and t can be tested for equality by the method invocation s.equals(t).
3.10.5 Strings computed at run time are newly created and therefore distinct. |
14.9.7 (p. 167) 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. [Note: the reference type equality operators can be used to compare string references instead of string values. end note] |
Io voto per .NET :-)