Without generics, I would like to pass a type as a parameter to a function without instantiating the type . The processing function must be able to limit the type, for example (for example, using System.Enum) there can be any type:
enum QuestionTypes { Great, Good, Huh, Dumb, Dumber }
static void Main(string[] args) { TypeHandler(QuestionTypes); }
static void TypeHandler(System.Enum enumType) { }
This is not the same as passing a type name, string, or instance. It seems reasonable that .NET should be able to pass in a type since the definition exists in compiled code. Is this work just for reflection, or can it be done without?
source
share