I don't think this is possible in C# but is there any way to iterate a list of generic arguments? Something like this:
public class Test<T, T1, T2, T3, T4>
{
public void DoIt()
{
foreach (var TItem in [T, T1, T2, T3, T4])
{
var foo = SomeService.Get<TItem>();
/* or */
var bar = new List<TItem>();
}
}
}
Pretty sure the answer is no due to CLR limitations but wanted to see if there's any way to accomplish this. I know you can do:
this.GetType().GetGenericArguments()
...but that yields a list of runtime Type objects which is not what I'm looking for.