不使用C#中的正则表达式进行不区分大小写的替换?

Ran*_*ana 5 c# c#-4.0

有没有办法在不使用C#中的正则表达式的情况下对字符串进行不区分大小写的替换?

这样的事情

string x = "Hello";

x = x.Replace("hello", "hello world");
Run Code Online (Sandbox Code Playgroud)

Adr*_*der 5

你可以尝试类似的东西

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);
Run Code Online (Sandbox Code Playgroud)

看看String.IndexOf方法(String,StringComparison)