I think it would be clearer if I asked the same question as you did, but used List<T>
instead of the anomous type:
If I do
new List<int>().GetType().GetGenericArguments()
, I'm gettingint
as I expect. But if I look at theList
type in mscorlib, it shows the generic typeT
, notint
. Why?
Do you see the difference? In the first case, you have a constructed type (e.g. List<int>
). But when you look at the assembly, you will see only the generic type definition (e.g. List<T>
). The constructed type is created only when you actualy instatiate the generic type definition with some generic parameters.
If you're interested in knowing why are all anomous types generic at all, read Eric Lippert's article Why are anonymous types generic?