What is the difference between the following two method signatures:
public static void test<T>()
vs
public static void test(Type t)
I know that the second one allows a type to be passed to the method but I am not clear on exactly what the first one is doing differently.
With the former, your type must be known at compile time, and you will able to use “T” within the method as a stand-in for the name of the type for things like variable declarations or casting as if you were writing normal code.
With the latter the type might not be known until runtime, but you will have to use reflection or dynamic objects to accomplish certain things that would be much easier (and type-safe) with the generic.