Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

c# List<int> in class

Name: tt 2011-03-05 12:18

So i made a class and put a public List<int> in there. Seems like every element in that class is using the same list. Even though i have new list() in the constructor.

Can anybody help?

Name: Anonymous 2011-03-05 12:35

>>18
You are correct in your assumption that a C# struct is a value type. However, this means that all fields are copied during an assignment (struct1 = struct2;), and when a field contains a reference, the reference is simply copied (a new object is not created!).

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List