Hi have :
struct A
{
public int val;
}
class OtherClass
{
private lis = new ArrayList();
public void Add(ref A element)
{
lis.Add(element);
}
public void SumAll(int num)
{
for (int i=0;i<lis.Count;i++)
{
A work = (A) lis[i]t;
work.val += num;
lis[i] = work;
}
}
}
in code :
A test1 = new A();
A test2 = new A();
test1.val = 5;
test2.val = 7;
OtherClass.Add( ref test1);
OtherClass.Add( ref test2);
OtherClass.SumAll(10);
here I want :
test1.val = 15 and test1.val = 17;
but I get :
test1.val = 5 and test2.val = 7;
What kind of collection is rigth for this ?
thks,
Paulo.