I can initialize a List<int> like new List<int>{1,2,3,4,5};
However List<T> does not have a constructor which accepts a single parameter.
So I tried to run this through the debugger and it seems to be calling the Add method.
So how does the compiler know which method to invoke to add each individual element.
This may be a silly question but I am a bit confused.
Thanks
Every type that has the method Add and implements IEnumerable can be initialized this way.
The compiler just compiles your code as if you used this Add method.
take a look here