List
string colorToTest = "RED";
myList.AddRange(new string[] { "red", "blue", "green" });
bool colorPresent = myList.Contains(colorToTest); // returns false
colorPresent = myList.Exists(delegate(string str){
return str.Equals(colorToTest, StringComparison.OrdinalIgnoreCase);
}); // returns true
Maybe using extension methods i can provide a case insensitive Find to a List.
BTW, you can get a case insensitive Hashtable by passing StringComparer.Ordinal in its ctor.
No comments:
Post a Comment