<分区>
Possible Duplicate:
Case insensitive contains(string)
使用 String 类的 Contains()
方法可以找到一个子字符串。
如何以不区分大小写的方式在字符串中查找子串?
<分区>
Possible Duplicate:
Case insensitive contains(string)
使用 String 类的 Contains()
方法可以找到一个子字符串。
如何以不区分大小写的方式在字符串中查找子串?
最佳答案
您可以使用 IndexOf() 方法,它接收一个 StringComparison 类型:
string s = "foobarbaz";
int index = s.IndexOf("BAR", StringComparison.CurrentCultureIgnoreCase); // index = 3
如果未找到字符串,IndexOf() 返回 -1。
关于c# - 以不区分大小写的方式查找子字符串 - C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8494703/