Recently ReSharper suggested in my Visual Studio 2010 solution that I could use optional parameter in one of my methods. I was surprised, as project was targeted to .NET 3.5 and as far as I know optional parameters were introduced with C# 4.0.
But I made a change and it compiled.
On the other hand I tried if covariance and contravariance work with .NET Framework 3.5 generic IEnumerable, and it didn’t. Could you advise what piece of knowledge I’m missing?
Variance for generic interfaces and delegates was introduced in the .NET Framework 2.0, but only useable to developers until the C# 4.0 compiler was able to take advantage of that.
It wasn’t until the .NET Framework 4 that the framework’s library types were updated for this type of variance. .NET 3.5 generic variance works fine with the C# 4 compiler, but only with your own types. This compiles just fine on the .NET Framework 3.5 with the C# 4 compiler.
Peter Richie left a comment that bears enough importance that it should be a part of the answer: