C# String Equals(String)
Description
String Equals(String)
determines whether this instance
and another specified String object have the same value.
Syntax
String.Equals(String)
has the following syntax.
public bool Equals(
string value
)
Parameters
String.Equals(String)
has the following parameters.
value
- The string to compare to this instance.
Returns
String.Equals(String)
method returns true if the value of the value parameter is the same as this instance; otherwise,
false.
Example
The following example demonstrates the Equals method.
using System;//from w w w. j a v a 2 s. c om
public class Example
{
public static void Main()
{
Console.OutputEncoding = System.Text.Encoding.UTF8;
string word = "File";
string[] others = { word.ToLower(), word, word.ToUpper(), "f1le" };
foreach (string other in others)
{
if (word.Equals(other))
Console.WriteLine("{0} = {1}", word, other);
else
Console.WriteLine("{0} {1} {2}", word, '\u2260', other);
}
}
}
The code above generates the following result.