C# by Jarvis

Comparing Strings Ignoring Case in C#

In C#, to compare two strings ignoring case sensitivity, you can use the string.Equals method with StringComparison.OrdinalIgnoreCase as shown below:

string val = "aStringValue";
bool isEqual = string.Equals(val, "astringvalue", StringComparison.OrdinalIgnoreCase);

This code snippet compares the val string with "astringvalue" regardless of case sensitivity and returns a boolean indicating if they are equal.

For more details and discussions about comparing strings in C# while ignoring case, you can refer to this Stack Overflow thread: Comparing two strings ignoring case in C#.

Comments