I'd like the compiler to infer a type for me, but am unsure if it is possible, or what the best alternative might be.
I'd like to do:
public static TValue Get<TValue>(TKey key) where TValue : Mapped<TKey> { ... }
public class MyObject : Mapped<int> { ... }
And have C# infer that TKey
is an int
. Is there any way to do something like this? If not, what would be the best alternative?
I'd like to avoid doing something like Get<MyObject, int>(1);
Edit:
For anyone who sees this in the future, similar questions have been asked here and here