<分区>
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/
相关文章:
.net - 如果我在 GAC 中有两个同名的程序集,我如何告诉 .Net 使用哪个程序集?
.net - 打开位于 addin 文件夹中的 XML 文件
.net - Azure.Identity 库(例如 DefaultAzureCredential)是否支持 token 缓存?
c# - 在 .NET Compact Framework 的托管代码 (C#) 中使用非托管 (C) 缓冲区
c# - 并行线程中的多个 dbcontext,EntityException "Rerun your statement when there are fewer active users"