Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

String.Equals Method (String, String, StringComparison)

Determines whether two specified String objects have the same value. A parameter specifies the culture, case, and sort rules used in the comparison.

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

static member Equals : 
        a:string * 
        b:string * 
        comparisonType:StringComparison -> bool

Parameters

a
Type: System.String

The first string to compare, or a null reference (Nothing in Visual Basic).

b
Type: System.String

The second string to compare, or a null reference (Nothing in Visual Basic).

comparisonType
Type: System.StringComparison

One of the enumeration values that specifies the rules for the comparison.

Return Value

Type: System.Boolean
true if the value of the a parameter is equal to the value of the b parameter; otherwise, false.

ExceptionCondition
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 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.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8

Portable Class Library

Supported in: Portable Class Library
Show:
© 2015 Microsoft