avatar
c*o
1
When I want to add an arrayList's content to another ArrayList,i.e.
al.add(alSon), C# adds the reference of alSon rather than its value to al. Any
one know how to figure it out if I only want to add a content of alSon to al,
and then the content of alSon will be refreshed and added to the al in a loop?
Currently, because the reference of alSon is used, so only duplicated values
of the last asSon are added to al.
Thank you!
ArrayList al=new ArrayList()
ArrayList alSon=new ArrayList()
for (...){
avatar
d*r
2
al.add(alSon.Clone());

Any
al,
loop?

【在 c*o 的大作中提到】
: When I want to add an arrayList's content to another ArrayList,i.e.
: al.add(alSon), C# adds the reference of alSon rather than its value to al. Any
: one know how to figure it out if I only want to add a content of alSon to al,
: and then the content of alSon will be refreshed and added to the al in a loop?
: Currently, because the reference of alSon is used, so only duplicated values
: of the last asSon are added to al.
: Thank you!
: ArrayList al=new ArrayList()
: ArrayList alSon=new ArrayList()
: for (...){

avatar
r*e
3
try
al.AddRange(alsSon)

Any
al,
loop?

【在 c*o 的大作中提到】
: When I want to add an arrayList's content to another ArrayList,i.e.
: al.add(alSon), C# adds the reference of alSon rather than its value to al. Any
: one know how to figure it out if I only want to add a content of alSon to al,
: and then the content of alSon will be refreshed and added to the al in a loop?
: Currently, because the reference of alSon is used, so only duplicated values
: of the last asSon are added to al.
: Thank you!
: ArrayList al=new ArrayList()
: ArrayList alSon=new ArrayList()
: for (...){

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。