I need to use reflection in C# and i know it have a Type object that let you work with reflection like Java’s Class do, but i need to specify a type or subtypes like the Java code below:
public class Test{
class Test2 extends Test { }
public static void doSomething(Class<? extends Test> myClass){
//doSomething with class...
}
public static void main(String[] args){
doSomething(Test2.class); //ok
doSomething(String.class); //error
}
}
In the .NET framework, Type isn’t generic. There’s only one type Type. You can’t specific that you only want a Type that describes a type derived from a given type, at least not statically.
You can of course do