How can I create a generic with two parameter where the second parameter is dependent on the first. In this case I'm creating a hash class, where I need both the type of the object and the key that identifies it.
Some simplified code for explanation:
class MyCache<T,Key> : where T is CommonImpl {
Dictionary<Key,T> cache;
T Get( Key v ) {
...
var newValue = new T(v);
return newValue;
}
}
class ImplA : CommonImpl {
public ImplA( String key ) { }
}
class ImplB : CommonImpl {
public ImplB( SomeType key ) { }
}
Where I have two uses of this cache MyCache<ImplA,String> and MyCache<ImplB,SomeType>.
Value, and how can it beImplAandImplBat the same time?