A simple extension method to compare string values without having to worry about case sensitivity.
Code:
public static bool IsEqual(this string Value, string CompareValue) { bool ReturnValue = false; if (Value != null && CompareValue != null) { ReturnValue = string.Compare(Value.Trim(), CompareValue.Trim(), StringComparison.OrdinalIgnoreCase) == 0; } return ReturnValue; }
Example usage:
if (Users.Any(x => x.FirstName.IsEqual(FirstName) && x.LastName.IsEqual(LastName))) { // code }
0 comments: