在运行时分配实例名称 [英] Assign Instance name at runtime

查看:73
本文介绍了在运行时分配实例名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有班级''学生'',我想创建班级''学生''的多个实例,并希望将实例名称分配为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.


得到了答案这里


这篇关于在运行时分配实例名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆