Equals Method (String, StringComparison)
Collapse the table of content
Expand the table of content

String.Equals Method (String, StringComparison)

 

Determines whether this string and a specified String object have the same value. A parameter specifies the culture, case, and sort rules used in the comparison.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

member Equals : 
        value:string *
        comparisonType:StringComparison -> bool

Parameters

value
Type: System.String

The string to compare to this instance.

comparisonType
Type: System.StringComparison

One of the enumeration values that specifies how the strings will be compared.

Return Value

Type: System.Boolean

true if the value of the value parameter is the same as this string; otherwise, false.

Exception Condition
ArgumentException

comparisonType is not a StringComparison value.

The comparisonType parameter indicates whether the comparison should use the current or invariant culture, honor or ignore the case of the two strings being compared, or use word or ordinal sort rules.

The following example creates a string array that consists of an uppercase "I", a lowercase "i", and a dotless "ı". It then calls the Equals(String, StringComparison) method to compare them by using each possible StringComparison enumeration value.

No code example is currently available or this language may not be supported.

The following example compares four sets of words by using each member of the StringComparison enumeration. The comparisons use the conventions of the English (United States) and Sami (Upper Sweden) cultures. Note that the strings "encyclopædia" and "encyclopedia" are considered equivalent in the en-US culture but not in the Sami (Northern Sweden) culture.

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 8
.NET Framework
Available since 2.0
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show:
© 2016 Microsoft