And why doesn't it shows the real type (eg: List<string> instead of List`1)?
Where does this strange (to me) notation comes from?
views:
147answers:
3The CLR name for generic List<T>
with one type parameter is
System.Collections.Generic.List`1
List<T>
is the C# style of naming that type.
The notation is a convention defined to give you the ability to overload generic types by parameter count. If you declare a class named List
with two type parameters (e.g. List<T,U>
) the compiler would be able to choose the right one. It'll be named:
System.Collections.Generic.List`2
and a non-generic List
class will be named:
System.Collections.Generic.List
Note that the CLR does not require generic types to be named like that. It's just a convention for the compilers to be able to pick the right type.
It doesn't show List<string>
because that's C# dependent syntax. A List in .Net source code could be declared as List<string>
, List(Of String)
or any of the other 60 or so languages/syntaxes that can compile down to MSIL.
So what you're seeing is the more generic MSIL syntax.
The `1 means that it is a List that has one generic parameter.
The `1 is MSIL syntax for a generic type - List<T> is C#-specific. More MSIL examples:
List<T> == System.Collections.Generic.List`1
List<string> == System.Collections.Generic.List`1[System.String]
Dictionary<string, int> == System.Collections.Generic.Dictionary`2[System.String,System.Int32]