The following methods allow culture-aware or case-insensitive comparisons:
public static bool Equals(string a, string b,StringComparison comparisonType); public bool Equals(string value, StringComparison comparisonType);
StringComparison is an enum defined as follows:
public enum StringComparison{ CurrentCulture, // Case-sensitive CurrentCultureIgnoreCase, InvariantCulture, // Case-sensitive InvariantCultureIgnoreCase, Ordinal, // Case-sensitive OrdinalIgnoreCase }
For example:
using System; class MainClass/*from w w w.jav a 2 s . c o m*/ { public static void Main(string[] args) { Console.WriteLine (string.Equals ("foo", "FOO", StringComparison.OrdinalIgnoreCase)); // True } }