namespace ConsoleApplication2
{
public static class Filter
{
public static IEnumerable<string> ForUser(this IEnumerable<string> qry, string userName)
{
return from a in qry
where
a.Contains(userName.ToLower())
select a;
}
/// <summary>
/// 自定义起用调用static方法过滤
/// </summary>
public static void CustExample()
{
IEnumerable<string> x = new List<string> { "1", "zzq", "good" }; //为对象赋值
foreach (var item in x.ForUser("zzq"))
{
Console.WriteLine(item);
}
}
}
}