StringComparer.CurrentCulture Property


Gets a StringComparer object that performs a case-sensitive string comparison using the word comparison rules of the current culture.

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

static member CurrentCulture : StringComparer with get

Property Value

Type: System.StringComparer

A new StringComparer object.

TheStringComparer returned by the CurrentCulture property can be used when strings are linguistically relevant. For example, if strings are displayed to the user, or if strings are the result of user interaction, culture-sensitive string comparison should be used to order the string data.

The current culture is the CultureInfo object associated with the current thread.

The CurrentCulture property actually returns an instance of an anonymous class derived from the StringComparer class.

Each call to the CurrentCulture property get accessor returns a new StringComparer object, as the following code shows.

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

To improve performance, you can store the StringComparer object in a local variable rather than retrieve the value of the CurrentCulture property multiple times.

The following code example demonstrates the properties and the Create method of the StringComparer class. The example illustrates how different StringComparer objects sort three versions of the Latin letter I.

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
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top