Possible Duplicate:
Why doesn’t C# infer my generic types?
Let's say we have such a method and a class:
Result<TOut> SendMessage<TIn, TOut>(TIn message)
where TIn : IMessage<TOut>
{
}
class Message : IMessage<string>
{
}
Why can't it resolve types when I invoke it like so:
var message = new Message();
var result = SendMessage(message);
We have Tin and we have constraint on Tin, so from there we can know Tout. But why it's not working?
If I write
var result = SendMessage<Message, string>(message);
It obviously works, but this is not much convenient.