public delegate TOutput Converter<in TInput, out TOutput>(TInput input)
What is the meaning of in
and out
in this declaration?
public delegate TOutput Converter<in TInput, out TOutput>(TInput input)
What is the meaning of in
and out
in this declaration?
Here's a great article from Eric Lippert's blog that explains the in and out keywords. They're used to express Covariance and Contravariance in generic type parameters.
What's the difference between covariance and assignment compatibility?
He also did a great 11 part series of articles on Covariance and Contravariance before it became a feature of C# 4. I'd highly recommend reading them as they will really help you grasp the concepts.
I've just checked and they're not linked to each other (and there's no easy way to just link to the series that I can find), so here's a table of contents.