// below function is replacement for such condition if(reallyLongStringVariableName == "string1" ||
// reallyLongStringVariableName == "string2" ||
// reallyLongStringVariableName == "string3")
//{
// // do something....
//}
public static bool In(this T source, params T[] list)
{
if (null == source) throw new ArgumentNullException("source");
return list.Contains(source);
}
Monday, January 30, 2012
Best Extension Methods: Is Matching with one of any String
Using below extension method we can check that a value is matching with one of any parameter or not...
Share This!
Labels:
C#.NET,
Extension Methods
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment