C# StringComparer Create

Description

StringComparer Create creates a StringComparer object that compares strings according to the rules of a specified culture.

Syntax

StringComparer.Create has the following syntax.


public static StringComparer Create(
  CultureInfo culture,
  bool ignoreCase
)

Parameters

StringComparer.Create has the following parameters.

  • culture - A culture whose linguistic rules are used to perform a string comparison.
  • ignoreCase - true to specify that comparison operations be case-insensitive; false to specify that comparison operations be case-sensitive.

Returns

StringComparer.Create method returns A new StringComparer object that performs string comparisons according to the comparison rules used by the culture parameter and the case rule specified by the ignoreCase parameter.

Example

The following code example demonstrates the properties and the Create method of the StringComparer class.


/*from   w  w w . j a v a  2s. co m*/

using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Threading;

class Sample 
{
    public static void Main() 
    {
        CultureInfo turkish = new CultureInfo("tr-TR");
        StringComparer turkICComp = StringComparer.Create(turkish, true);
        Console.WriteLine(turkICComp.ToString());
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version