If I have a switch-case statement where the object in the switch is string, is it possible to do an ignoreCase compare?
I have for instance:
string s =
10 years later, with C# pattern matching, you can do something like:
private string NormalisePropertyType(string propertyType) => true switch
{
true when string.IsNullOrWhiteSpace(propertyType) => propertyType,
true when "house".Equals(propertyType, StringComparison.OrdinalIgnoreCase) => "house",
true when "window".Equals(propertyType, StringComparison.OrdinalIgnoreCase) => "window",
true when "door".Equals(propertyType, StringComparison.OrdinalIgnoreCase) => "door",
true when "roof".Equals(propertyType, StringComparison.OrdinalIgnoreCase) => "roof",
true when "chair".Equals(propertyType, StringComparison.OrdinalIgnoreCase) => "chair",
_ => propertyType
};