I noticed that the behavior of List<T> is different from an other simple object, say String for example. The question can seem newbie but that really struck me cause I thought that List<T> were simple objects.
Take for instance the following code:
List<String> ls1 = new List<String>();
ls1.Add("a");
List<String> ls2 = ls1;
ls1.Add("b");
At the end, ls1 will be equal to {"a", "b"} and so will ls2. This is really different from the behavior of this code:
String s1 = "a";
String s2 = s1;
s1 = "b";
Where s1 is at the end equal to b and s2 equal to a.
That means that List<T> is in fact a pointer right?
List<T>a reference type, so yes it behaves like a pointer.Stringis also a reference type, but strings are immutable and they behave like value types (contrast with reference types) in some cases hence your confusion here.There is a good explanation of why string work this way here: In C#, why is String a reference type that behaves like a value type?