Instantiating Generic class using field type at runtime
c#, generics
Solution
It takes a compile-time type, like so:
ValueRange<int> range;
It's also worth noting that you typically name your types "T"; it's just the generally-accepted standard (and hence nice to read).
Problem
First question here. I am trying to instantiate a generic class using the type of a field. ``` public class ValueRange<type1> { type1 min; type1 max; } void foo() { int k; ValueRange<k.GetType()> range; } ``` This doesn't work. Any suggestions? Thanks in advance