问题描述:

CLocation is a C++CLI value class (would be a struct in C#) with public members x, y, z.

List<CLocation>^ listloc = gcnew List<CLocation>;

listloc->Add (CLocation (1,2,3));

listloc[0].x = 5; // FAILS, '5' is not stored.

array<CLocation>^ aloc = gcnew array<CLocation>(1);

aloc[0] = CLocation (1,2,3);

aloc[0].x = 5; // WORKS

Why is 5 not saved in the member of the object in the list, while it is perfectly saved in the member of the object of the array?

Does list access return a copy of the object as Marc Gravell wrote in In C#, are the values in a List<struct> boxed? ?

相关阅读:
Top