Extract Generic Type Definition in C#
void Main()
{
GetTypeFromList(new List<string>()).Dump();
GetTypeFromFunc((string s, int i) => true).Dump();
}
public Type GetTypeFromList<TType>(IEnumerable<TType> dummy)
{
return typeof(TType);
}
public Type[] GetTypeFromFunc<T1, T2, TOut>(Func<T1, T2, TOut> dummy)
{
return new [] { typeof(T1), typeof(T2), typeof(TOut) };
}