Case insensitive replace without using regular expression in C#?

c#, c#-4.0

Solution

You can try something like

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);

Have a look at String.IndexOf Method (String, StringComparison)

Problem

Is there a way to do case insensitive replace on a string without using regular expression in C#? something like this ``` string x = "Hello"; x = x.Replace("hello", "hello world"); ```

Original source

Related problems