C# String Equals(String, String)
Description
String Equals(String, String)
determines whether two
specified String objects have the same value.
Syntax
String.Equals(String, String)
has the following syntax.
public static bool Equals(
string a,
string b
)
Parameters
String.Equals(String, String)
has the following parameters.
a
- The first string to compare, or null.b
- The second string to compare, or null.
Returns
String.Equals(String, String)
method returns 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.
Example
The following code shows how to use
String.Equals(String, String)
method.
/* ww w .ja v a2 s . co m*/
using System;
using System.Text;
class Sample {
public static void Main() {
String str1 = "abcd";
String str2 = null;
Console.WriteLine(String.Equals(str1, str2));
}
}
The code above generates the following result.