Using below extension method we can check that a value is matching with one of any parameter or not...
// 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);
}
9:49 AM
Rajesh Rolen
0 comments:
Post a Comment