I have a method like public static TOut Method<TIn, TOut>(TIn in)
with constraint where TIn: class, Interface<TOut>
.
Do I always need to write Method<ClassIn, ClassOut>(ObjectIn);
when I use it, or is there some way to make the TIn
inferred by arguments so I only need to write Method<ClassOut>(ObjectIn);
? The ClassOut
varies from time to time so I can't write a static class for it every time.
Also, is it right that C# cannot infer types from the constraints so it is impossible to make both TIn
and TOut
inferred?