How is memory allocated when you create a property of class?
问题 I have the following class: public class A { public List<string> AList { get; set; } } Then I create object of a class: A objectA = new A(); objectA.AList = new List<string>() { "1", "2", "3" }; My question is how memory will be allocated in a heap? I mean will be objectA.AList allocated inside of objectA (image1) or as a separate object in a heap(image2) Image1: Image2: 回答1: The correct answer is : Image 3. I'm not going to draw this but your example leads to 5 objects on the Heap. Objects