lundi 4 juin 2018

Why does IsGenericTypeDefinition return false?

I am trying to understand IsGenericTypeDefinition property of Type. As I understand, it is just class template without any substituted types (and we cannot create instance of this class). Here is code of my test program:

class Test
{
    public class MyList<T> : List<T>
    {
    }
    public static void Main()
    {
    Console.WriteLine(typeof(MyList<>).GetMethod("Add").DeclaringType.IsGenericTypeDefinition);
    }
}

Why does program print false ? I just get this method info from generic type definition. Why does it have not generic declaring type definition? Is it bug?





Aucun commentaire:

Enregistrer un commentaire