The code is:
struct m1
{
public int a;
public int b;
}
int main()
{
List <m1> mList;
m1.initialize;
//new. and add some items to it.
now I want to access the objects in mList at first I tried:
for each(m1 it in mList)
{
m1.a = 5;
}
but it failed. becuase after the for each I wrote m1.first().a on console. it was it's initialized value not 5.
then I tried
for (int counter = 0; counter < mList.size(); counter++)
{
m1 it = mList[counter];
it.a = 5;
}
again the same problem.
then I tried
for (int counter = 0; counter < mList.size(); counter++)
{
mList[counter].a = 5;
}
it even didn't compiled. it gives me an error. it says something about not being modifiable return value of list.this[int].
then I tried
for (int counter = 0; counter < mList.size(); counter++)
{
var m1 it = mList[counter];
it.a = 5;
}
it didn't work too. I tried all I could and everything that I found in internet and this site. Could you please help you to find a way to access parameters of objects(of type struct) in list? Obviously it is easy when list is made from objects(from classes). it comes to complication if I want to made a list from objects of structs. Any help would highly welcomed.