Can I have a type that's both, covariant and contravariant, i.e. fully fungible/changeable with sub
- by Water Cooler v2
Just a stupid question. I could try it out in 2 minutes, really. It's just that I have 1 GB RAM and have already got 2 instances of VS 2010 open on my desktop, with an instance of VS 2005, too. Opening another instance of VS 2010 would be an over kill.
Can I have a type (for now forgetting its semantics) that can be covariant as well as contravariant?
For e.g.
public interface Foo<in out T>
{
void DoFooWith(T arg);
}
Off to Eric Lippert's blog for the meat and potatoes of variance in C# 4.0 as there's little else anywhere that covers adequate ground on the subject.