Log the Type of a Type Parameter to the Console in C#

SEPTEMBER 3, 2019

If you are inside of a function which uses a type parameter—T—you can do a Console.WriteLine, for instance, to inspect what type is being used on a given function call.

Console.WriteLine(typeof(T));
// System.object or other type

CodeC#