Consider this simple code:
class Program
{
static List<Data> listData = new List<Data>();
static void Main(string[] args)
{
for (int i = 0; i < 5; i++)
{
Data newData = new Data();
newData.num1 = i;
newData.num2 = i * 5;
listData.Add(newData);
}
Console.ReadLine();
}
}
class Data
{
public int num1 { get; set; }
public int num2 { get; set; }
}
For some reason, when profiling memory for this code, it shows that there are 2 Data[] objects in memory (which i assume are listData objects):
Can anyone explain why?