using System.Collections.Generic;
IList<Animal> a;
a=new List<Animal>();//不用集合,ilist,用泛型
a.Add(new Cat("猫a"));
a.Add(new Dog("狗a"));
MessageBox.Show(a.Count.ToString());
a.RemoveAt(0);
只要是集合,就可调用[]
返回一组对象时可用接口iList
//获取的用户ID
public List<int> GetUserId(int Id)
{
List<int> userId = new List<int>();
SqlDataReader dr = BaseDAL.GetRecord(table, field, where, null);
while (dr.Read())
{
userId.Add(dr.GetInt32(0));
}
dr.Close();
return userId;
}