Is it possible to have a generic constraint which is an unbounded generic type?
For example:
public T DoSomething<T>(T dictionary) where T : IDictionary<,>
{
...
}
Edit: Just to explain the context, I want to constrain the usage of the method to an IDictionary, but for the method itself it does not matter exactly what TKey and TValue are.
public V DoSomething<K,V>(IDictionary<K,V> dictionary)
Is this what you meant? – SilvioT
? Are you going to return the parameter? There's probably no need for that. And you can't easily construct anotherT
. Unless you want to constraintT : new()
as well. – Barrows