Reputation: 1031
I have string like "Helloworld" and a substring of that like "world" now , how can I find the index of the first char of the substring in the main string ? in this case I want the index of 'w' in "Helloworld"
can anyone help me please ?
Upvotes: 1
Views: 125
Reputation: 216293
I suggest to use the string.IndexOf, but specifically the overload that accepts the StringComparison enum
string test = "HelloWorld"; // World in uppercase
int pos = test.IndexOf("world", StringComparison.CurrentCultureIgnoreCase);
Console.WriteLine(pos.ToString());
Upvotes: 4