C# StringComparer InvariantCultureIgnoreCase

Description

StringComparer InvariantCultureIgnoreCase gets a StringComparer object that performs a case-insensitive string comparison using the word comparison rules of the invariant culture.

Syntax

StringComparer.InvariantCultureIgnoreCase has the following syntax.


public static StringComparer InvariantCultureIgnoreCase { get; }

Example


using System;// ww w .  j a  v  a 2 s .com
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Threading;

class Sample 
{
    public static void Main() 
    {
        List<string> list = new List<string>();
        StringComparer invCmp =   StringComparer.InvariantCultureIgnoreCase;
    
        string capitalLetterI = "I";  
        string smallLetterI   = "i";
        string smallLetterDotlessI = "\u0131";
    
        list.Add(capitalLetterI);
        list.Add(smallLetterI);
        list.Add(smallLetterDotlessI);
    
        list.Sort(invCmp);
    }

}

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