Difference between case insensitive strings?

Possible duplicate:
What is usually best to use - StringComparison.OrdinalIgnoreCase or StringComparison.InvariantCultureIgnoreCase?

When using String.Equals (string a, string b, StringComparison compareType) and not caring about the case of "a" and "b", what should be used to use StringComparison correctly? In other words, what is the difference between StringComparison.CurrentCultureIgnoreCase, StringComparison.InvariantCultureIgnoreCase and StringComparison.OrdinalIgnoreCase and how will each affect the use of String.Equals?

+3
source share
1 answer

, . , "u" "U" en-us, - - .

, :

        CultureInfo english = new CultureInfo("en-US", false);
        CultureInfo turkish = new CultureInfo("tr-TR", false);

        foreach (String i in new String[] { "a", "e", "i", "o", "u" })
        {
            String iEng = i.ToUpper(english);
            String iTur = i.ToUpper(turkish);
            Console.Write(i); 
            Console.WriteLine(iEng == iTur ? " Equal" : " Not equal");
        }

        Console.ReadLine();

, , , , . CurrentCultureIgnoreCase, , .

+2

Source: https://habr.com/ru/post/1710287/


All Articles