I have built myself a generic collection class which is defined like this.
public class StatisticItemHits<T>{...}
This class can be used with int
and string
values only. However this
public class StatisticItemHits<T> where T : string, int {...}
won't compile. What am I doing wrong?
You could make
StatisticItemHits<T>
an abstract class and create two subclasses:StatisticItemHitsInt : StatisticItemHits<int>{}
StatisticItemHitsString : StatisticItemHits<string>{}
That way there can only be an int and string-representation of StatisticItemHits