17 June 2009

System.Array.IndexOf to check if item exists without looping

public static string someMethod(parameterList ....., string[] filter)
{

foreach (DataRow item in dt.Rows)
{
if (
System.Array.IndexOf(filter, item["itemName"].ToString()) > -1)
collection.Add(item);
}

return collection;
}

No comments: