如补充内容class Program{static void Main(string[] args){Program p = new Program();Person pp = new Person();p.getList(pp);}public List getList(object ob){Type type = ob.GetType();return List;}}怎么我想返回个List这个list该怎么做?
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/15 06:18:56
如补充内容class Program{static void Main(string[] args){Program p = new Program();Person pp = new Person();p.getList(pp);}public List getList(object ob){Type type = ob.GetType();return List;}}怎么我想返回个List这个list该怎么做?
如补充内容
class Program
{
static void Main(string[] args)
{
Program p = new Program();
Person pp = new Person();
p.getList(pp);
}
public List getList(object ob)
{
Type type = ob.GetType();
return List;
}
}
怎么我想返回个List这个list该怎么做?
如补充内容class Program{static void Main(string[] args){Program p = new Program();Person pp = new Person();p.getList(pp);}public List getList(object ob){Type type = ob.GetType();return List;}}怎么我想返回个List这个list该怎么做?
public List getList(T ob)
{
List list= new List();
list.add(ob);
return List;
}
调用时只要写 p.getList(pp);就可以了,可以用于任何类型的list返回