I would like to be able to create new generic types using enum values. I believe this is possible with C ++ templates, but I don't know if it is possible to do this with C #.
So what I would like to do:
public class MyClass <T>
{
public void Do<T>() {}
}
public enum Metals
{
Silver, Gold
}
and I would like to list an enumeration like:
var myGoldClass = new MyClass<Metals.Gold>();
I think I could create classes called Gold, Silver to achieve this, but I really like to have enum to restrict the types of my general class.
The reason I want something like this in the real world is to create an event aggregator (publish-subscribe model), and I want my subscribers to subscribe to messages of a certain type T. Therefore, I thought it would be nice, if I could subscribe to subscribers using transfers.
EDIT:
, Metals.Gold - . , enums\classes . .