If A is a template for actual type, then why is typeof(A<,>) allowed?

后端 未结 3 777
不知归路
不知归路 2021-01-18 06:06
class Program
{
    static void Main(string[] args)
    {
        Type t = typeof(A<,>);
        Console.WriteLine(typeof(A<,>)); // prints A\'2[T1,T2]
          


        
3条回答
  •  误落风尘
    2021-01-18 07:04

    It is accepted because it is a generic type.

    It is an open generic type (where they type parameters have not been specified), but a type none the less.

    See the discussion here (What exactly is an “open generic type”).

    And on MSDN (typeof):

    The typeof operator can also be used on open generic types.

提交回复
热议问题