asp.net2.0(petshop4.0)返回值问题

来源:百度知道 编辑:UC知道 时间:2024/05/24 06:57:31
petshop4.0里面有一段代码是这样写的 我想仿照做一下 下面这个方法是根据ID获取了一条记录 我想把它获取的这一条记录分别负给5个lable控件 如果我要调用这个方法 应该怎样用什么类型来接受了 在分别负值给5个lable控件 非常感谢
public IList<companyEntity> getcompanyinfo(int sid)
{
}

int id=100;
IList<companyEntity> entity=getcompanyinfo(id);
if(entity.Count>0)
{
//取值 赋值
}

IList就是列表接口,支持插入删除和Foreach循环
而这个IList存储的值就是他的泛型类
比如
IList<companyEntity> companys = getcompanyinfo(id);

foreach( companyEntity Entity in companys)
{
Response.Write(Entity.Id);
}