Re: How to modify value in ArrayList?

From: cody (no_spam_deutronium_at_gmx.net)
Date: 12/03/04


Date: Fri, 3 Dec 2004 09:15:19 +0100

You cannot modify the value without removing and readding it, since as you
already noticed it is a boxed value type.

--
cody
Freeware Tools, Games and Humour
http://www.deutronium.de.vu  || http://www.deutronium.tk
"KalleD" <KalleD@discussions.microsoft.com> schrieb im Newsbeitrag
news:431AAEBB-11A8-4847-965B-5A89795BBCD5@microsoft.com...
> Given:
>
> ArrayList al=new ArrayList();
> int i=1;
> al.Add(i);
>
> How can I change the value of al[0] to 2?
> (without removing the object and then adding a new one)
>
> This won't work, since int is an value type object:
>
> int k=(int) al[0];
> k=2; //(al[0] is not updated since k is a not a referrence to it
>
> Is it possible?
>
> Best Regards
> Karl Daggfeldt


Relevant Pages