Ignoring the case-sensitiveness while comparing two strings in C#.

Vishalneeraj-24503
Posted by Vishalneeraj-24503 under Visual Studio category on | Points: 40 | Views : 209
Below is the best way to compare the string in C# and ignore the case-sensitivity.
string str_to_compare = "vishalNEERAJ";

if(str_to_compare.Equals("vishalneeraj",StringComparison.InvariantCultureIgnoreCase))
{
//code goes here.
}

Note:-StringComparison.InvariantCultureIgnoreCase will ignore the case-sensitivity.

Comments or Responses

Login to post response