c*o 发帖数: 70 | 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 (...){
| d*r 发帖数: 238 | 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 (...){
| r***e 发帖数: 38 | 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 (...){
|
|