I cant wrap my head around why I cant call a method with this signature:
public void Test(Tuple<int, IEnumerable<string>> x);
like that:
Test(Tuple.Create(4, new List<string>()))
I think this has to do with co/contravariance but thats just a guess. Can somebody share his cleverness?
Yes, the
Tupleclass is not marked as co- or contravariant, the reason being only interfaces can be co- or contravariant. So the type parameters have to match exactly. Here’s the reason why classes can’t be co- and contravariant.