在运行时分配实例名称
问题描述:
我有班级''学生'',我想创建班级''学生''的多个实例,并希望将实例名称分配为S1,S2,S3 ..等(1,2,3将是学生的id,因此实例名称将为S + StudentID)在运行时。我怎么能这样做?
谢谢。
Hi,
I have class ''Student'' , I want to create multiple instance of class ''Student'' and want to assign instance name as S1,S2,S3..etc(1,2,3 will be id of student , so instance name will be as S+StudentID) at runtime. How can i do this?
Thanks.
答
我会使用一个对象数组(或a 列表
)。几乎没有太多努力的效果。
I would use an array of objects (or a List
). Almost the same effect without too much effort.
得到了答案这里,