When I try to edit values in a list, by looping through it like the code below, I get the error "Cannot modify members of 'list' because it is a 'foreach iteration variable'".
foreach (Item item in my_list)
{
item.var = 3;
}
I also tried doing this with a for loop like this, and get the error "Cannot modify the return value of 'System.Collections.Generic.List<list>.this[int]' because it is not a variable"
for (int i = 0; i < my_list.Count; i++)
{
my_list.var = 3;
}
So how can you change the contents of a list in this way? Is the only way to add an entire new item to the list and remove the old item?