mardi 15 novembre 2016

How to distinguish between enclosing and nested type parameters using Reflection in .NET?

When I have a nested type like this:

public class MyOuter<T>
{
    public class MyInner { }
}

How do I tell, using Reflection on typeof(MyInner<int>) that the type parameter T is declared on MyOuter and not on MyInner ? When I call typeof(MyOuter<int>.MyInner).GetGenericArguments() it returns an array with typeof(int) and so does typeof(MyOuter<int>).GetGenericArguments().





Aucun commentaire:

Enregistrer un commentaire