IDG Contributor Network: C# 7 in depth : Exploring local functions

The support for local functions is an excellent new feature that has been introduced in C# 7. Note that you can define local functions inside any method, the constructor of a class or inside a property — both getter and setter. When it’s compiled by the C# compiler, a local function gets transformed into a private method.

When developing applications, you might often need to create methods that aren’t reused — you need them just for modularity. You might not want your methods to be long as maintaining such methods would become a nightmare over time. However, you might end up having many private methods that would not be reused, right? This new feature in C# 7 comes to the rescue in such circumstances — you can define functions that are local to another scope, or it can be inside another function or even inside a property (both getter and setter).

To read this article in full or to leave a comment, please click here

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s