Determines whether the current instance and the specified
object have the
same value.
[Edit]
[System.Runtime.ConstrainedExecution.ReliabilityContract(System.Runtime.ConstrainedExecution.Consistency.WillNotCorruptState, System.Runtime.ConstrainedExecution.Cer.MayFail)] public override bool Equals (object obj) |
|
Parameters
- obj
- A object.
[Edit]
Returns
true if obj is a string and its value is
the same as the value of the current instance; otherwise,
false.
[Edit]
Exceptions
Remarks
Example
The following example demonstrates checking to see if an object is equal to
the current instance.
C# Example |
using System;
public class StringEqualsExample {
public static void Main() {
string str = "A string";
Console.WriteLine( "The given string is '{0}'", str );
Console.Write( "The given string is equal to 'A string'? " );
Console.WriteLine( str.Equals( "A string" ) );
Console.Write( "The given string is equal to 'A String'? " );
Console.WriteLine( str.Equals( "A String" ) );
}
}
|
The output is
The given string is 'A string'
The given string is equal to 'A string'? True
The given string is equal to 'A String'? False
Requirements
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0