How to make String.Contains case insensitive?
Posted by Anuraj on Saturday, January 4, 2014
.Net .Net 3.0 / 3.5 .Net 4.0 ASP.Net Windows Forms
The string.Contains() method in C# is case sensitive. And there is not StringComparison parameter available similar to Equals() method, which helps to compare case insensitive.
If you run the following tests, TestStringContains2() will fail.
Other option is using like this.
And here is the case insensitive contains method implementation.
And here is the modified tests.
And here is the tests running
Happy Programming :)