List<Table> 的委托

项目中要用到类型(多种型号查找),所以我打算用委托;返回的是List<Table> .

string series = Request.QueryString["series"]; //接收不同型号的产品系列


if (!string.IsNullOrEmpty(series))
{
BLL.Productsdelegate getProductsType = new BLL.Productsdelegate();
DataList1.DataSource=getProductsType.GetProducts(series,getProductsType.GetType18);  // 返回List<Table> 绑定到控件上
DataList1.DataBind();
}

-------------------------------------------------

public delegate List<Products> GetProductType(string type);   //声明 委托类型是List<Table>

public class Productsdelegate
{
public List<Products> GetProducts(string type, GetProductType ProductsType)   // 方法返回的类型是List<Table>
{
return ProductsType(type);
}

public List<Products> GetType18(string type)
{
BLL.BLL_Products bll = new BLL_Products();
return bll.GetList().Where(T=>T.Type==type.ToUpper()).ToList();   //查询返回 List<Table>
}
public void GetType20(string type)
{
Console.Write("j20"); // 测试用的; 
// return type;
}

}

原文地址:https://www.cnblogs.com/liuming8208/p/2283882.html