I have a project where I want to keep a reference to a Type and later initalize instance of that type. But I want some compile-time type-checking so I only can provide types that implements the ITest interface. I think I have to change approach, but I can’t see how.
private static Type currentType = null;
public static void Initalize (Type current){
currentType = current;
}
public class Test : ITest{}
public class Test2 {}
It should be possible to pass in the typeof(Test) but not typeof(Test2)
Why dont you use generics?