Jason Anderson

Jason Anderson

  • NA
  • 7
  • 45k

How to update an ArrayList?

May 9 2011 11:22 AM

I have an ArrayList that I enumerate through and want to update a property (Class1 property) within the ArrayList.

arrayList = new ArrayList();
Class1 class1 = new Class1();
...
...
arrayList.Add(class1);
...
...
Class1 temp;
IEnumerator ie = arrayList.GetEnumerator();
while (ie.MoveNext())
{
...
...
...
temp = (Class1)ie.Current;
temp.PropertyA = Convert.ToInt32(objDataReader.GetValue(6));
...
...
...
}

I want arrayList to reflect the value change of PropertyA.

The value is updated in temp, but not in arrayList.

Thanks for your help.

Jason


Answers (4)