c# - 'List<T>.ForEach()' and mutability -
i want translate points in list<t>. works:
for (int = 0; <polygonbase.count; ++i) { polygonbase[i] = polygonbase[i] + mousepos; } but using list<t>.foreach doesn't:
polygonbase.foreach(v => v += mousepos); ideas?
your current code re-assigning local variable v new value - doesn't refer original value in list. it's equivalent of writing:
foreach(int v in polygonbase) { v += mousepos; } to write original value, use convertall:
polygonbase.convertall(v => v += mousepos);
Comments
Post a Comment