var a = new List<int>();
var b = a;
a.Add(5);
Console.WriteLine(a.Count); // prints 1
Console.WriteLine(b.Count); // prints 1 as well
Assigning to a variable of a List<int>
does not create a copy of the List<int>
. Instead, it copies the reference to the List<int>
. We call types that behave this way reference types.