Wednesday, April 29, 2009

Doing case insensitive search in C#.Net



It seems C# is doing case sensitive search by default.

Consider below two variables.

string name="QualityPoint"
string searchword="quality"

name.IndexOf(searchword) will return -1 as quality is different from Quality when doing case sensitive search.

If you want to make it a case insensitive search you should use as below
name.IndexOf(searchword,System.StringComparison.CurrentCultureIgnoreCase)
More Articles...

No comments:



Thanks for visiting our blog


twitterrss facebook linkedin YouTube subscribe


Subscribe via email

Enter your email address: