C# 7: Dissecting Local Functions to understand how they capture local variables

One of the new language features in C# 7 is local functions. This feature lets you define functions within the scope of other functions. The main benefit of local functions is encapsulation and a secondary benefit is that they bring local variables into scope.

Although local functions appear simple, their interaction with other language features quickly leads to questions. I wondered …

Read More

C# 7 Preview: Using tuples to return multiple values

Microsoft is hard at work on C# 7, the next version of C#. In this post, I'll look at tuples, one of the new features proposed for C# 7. So what are tuples, why do we need them, and how do they differ from what we have already.

Tuples are a way to temporarily group multiple values together. Currently, C# handles inputs and outputs asymmetrically. There is syntactic support for passing …

Read More