有没有办法在不使用 C# 中的正则表达式的情况下对字符串进行不区分大小写的替换?
像这样
string x = "Hello";
x = x.Replace("hello", "hello world");
最佳答案
你可以尝试类似的东西
string str = "Hello";
string replace = "hello";
string replaceWith = "hello world";
int i = str.IndexOf(replace, StringComparison.OrdinalIgnoreCase);
int len = replace.Length;
str = str.Replace(str.Substring(i, len), replaceWith);
关于c# - 在 C# 中不使用正则表达式进行不区分大小写的替换?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3993826/