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
It takes a compile-time type, like so:
It’s also worth noting that you typically name your types “T”; it’s just the generally-accepted standard (and hence nice to read).