我有 2 个清单。每个列表由其中的对象组成,即对象列表。
List<Book> listBook= new List<Book>();
List<Pen> listPen = new List<Pen>();
class Book {
string name;
int id;
Book() {
this.name = name;
this.id = id;
}
}
class Pen {
string name;
int id;
Pen() {
this.name = name;
this.id = id;
}
}
listBook其中有 10 个对象,同样也listPen有 10 个对象。
我需要一个add方法,通过传递列表对象或带有详细信息的列表的引用,列表必须更新。我的意思是,单一方法,使用 list-pen 或 list-book 调用该方法应该分别向 list-pen 或 list-book 添加新对象。
感谢您的任何建议或帮助
BIG阳
慕标琳琳
跃然一笑
相关分类