Static Arraylist?
-
hi i have a problem accessin the arraylist i made in a form by another form as i had to make static array and when i put data in it in for loop it just saves the last data the loop put what can i do? thanx
A static array exists only once. Anything you do to it will reflect elsewhere. Make it non static so that each instance has it's own array. If you are using a form, try calling the array from a non static method. You are probably trying to read it from main. :) Cata
-
A static array exists only once. Anything you do to it will reflect elsewhere. Make it non static so that each instance has it's own array. If you are using a form, try calling the array from a non static method. You are probably trying to read it from main. :) Cata
-
thanx but i don't need that each instance have its own array as i need the data from the array that i put in the 1rst form in the second to do changes in it then i need the changed array in the 3rd form
-
hi i have a problem accessin the arraylist i made in a form by another form as i had to make static array and when i put data in it in for loop it just saves the last data the loop put what can i do? thanx
You might want to post some code samples of your array and what your doing to modify it. RageInTheMachine9532
-
You might want to post some code samples of your array and what your doing to modify it. RageInTheMachine9532
((Offices)(OfficesNames[i])).OfficeAtt= new ArrayList(AllNodes); Offices ->class OfficesNames->array of object of offices officeAtt->arraylist have object of another class called attributes this line of code to intialize the arraylist of attributes of each office for(int i=0;i
-
hi i have a problem accessin the arraylist i made in a form by another form as i had to make static array and when i put data in it in for loop it just saves the last data the loop put what can i do? thanx
When you enumerate a collection or list (anything that implements
IEnumerable
, it isdocumented
behavior to throw an exception. This is to ensure that changes to the list or collection aren't skipped when looping. You can either clone the list or collection or use an iterative loop (for
, as opposed toforeach
).Microsoft MVP, Visual C# My Articles