out var
feature.Since writing that post, the leakage rules have changed, so I thought it time to revisit the topic.
Continue reading “C# 7, “out var” and changing variable scope, revisited”
out var
feature.Since writing that post, the leakage rules have changed, so I thought it time to revisit the topic.
Continue reading “C# 7, “out var” and changing variable scope, revisited”
Continue reading “Using C# 7 and Succinc<T> to give F# a run for its money”
out var
feature works. And suddenly that all changed. This minor feature has become a significant change to the language. And many people aren’t at all happy about it.
Continue reading “C# 7, “out var” and changing variable scope”
Reverse
method for strings. Taking a collection of characters and reversing them is easy; so why is it missing?
As I wanted such a method, and didn’t want to burden the library I was writing with a disconnected feature, I created the ReversedString
nuget package, which supplied it. Job done. Still, why isn’t it included in the standard framework? Experimenting with tests led me to a possible reason. Continue reading “When is a reversed string, not a reversed string?”
T
, for ISomeInterface<T>
, to be passed in, either via method parameters or through property setters (though good code will not contain the latter, of course). It’s perhaps no surprise that covariance is the opposite. Only when ISomeInterface<T>
allows instances of T
to be passed out (either via method returns, or property getters), can that interface be covariant.This is part 2 of a three part series on generic variance in C#. Part 1, covers invariance. The final part, covers covariance.
Continue reading “Generic variance in C#, part 2 — Contravariance”
The second part of this series, looks at what is probably the least well understood of the three terms: contravariance. If you feel you understand the other two terms, feel free to jump straight to that part therefore. The third, and last, part, looks at covariance and finishes with a summary of the difference between the three. But first, we start at the beginning: invariance.
Continue reading “Generic variance in C#, part 1 — Invariance”