方法1
string str=”AbcdEFG”;
str.IndexOf(“abc”, StringComparison.OrdinalIgnoreCase);
方法2
字符串的 IndexOf 方法是对大小写敏感的.幸运的是,这个Globalization 命名空间下包含CompareInfo类,它包含一个对大小写不敏感的 IndexOf 方法. 例如:
using System.Globalization;
string s1 = “C# is a GREAT programming language.”;
string s2 = “Great”;
CompareInfo Compare = CultureInfo.InvariantCulture.CompareInfo;
int i = Compare.IndexOf( s1, s2, CompareOptions.IgnoreCase );