Determines whether two specified string objects have the same value.
![]()
true if the value of a is the same as the value of b; otherwise, false. If both a and b are null, the method returns true.
The following example demonstrates checking to see if two strings are equal.
C# Example
using System;
public class StringEqualsExample {
public static void Main() {
string strA = "A string";
string strB = "a string";
string strC = "a string";
Console.Write( "The string '{0}' is equal to the string '{1}'? ", strA, strB );
Console.WriteLine( String.Equals( strA, strB ) );
Console.Write( "The string '{0}' is equal to the string '{1}'? ", strC, strB );
Console.WriteLine( String.Equals( strC, strB ) );
}
}
The output is
The string 'A string' is equal to the string 'a string'? False