[EN] New features in C# 7.0: local functions, ref returns and others

This is the third and the last post about new features in C# 7.0. Today I will focus on:
– local functions
– literal improvements
– ref returns
– few other minor improvements

Local functions

It means we can create local function in a method. I don’t think I will use it often. We can achieve similar effect with Func/Action delegates. Anyway it’s nice to have feature.

Literal imporvements

We can write numbers with separator _ to improve readability or use binary literals to specify bit patterns instead of hexadecimal.

Ref returns

In C# 7.0 we can use ref to return reference to the specific thing, e.g. get reference to item number 1 from an array and store this reference in local variable. I think it can be helpful mostly for game developers for passing ref to big data structures.

Few other improvements

In C# 7.0 we get more improvements. I just want to list them shortly.
– Async methods can return other types than void, Task and Task<T>,
– we can use expression bodies in more places, e.g. accessors, constructors, finalizers. We can create constructor like this

– we can throw an exception in an expression

That’s all new features that we can use in C# 7.0. Hope you use it well 😉