#VS2015 – C#6, using Expression Bodied Members … hell on earth !!!

Hola!

After String Interpolation and nameof now is time to write about a new cool feature in C#6: Expression Bodied Members. The Main purpose of this feature is to make the code more clean. If you are familiar with Lambda expressions, this feature is similar.

Let’s move to a sample with a Console app, with an operation GetName() to process some strings. C#5 mode will be similar to this:

In C#6 with the new Features, and Visual Studio 2015, the source code for GetName2() will implement an expression bodied members.

As always, if the code will be cleaner … Thanks !!!

References

– El Bruno, String Interpolation https://elbruno.com/2015/04/20/vs2015-string-interpolation-vs-string-format-your-team-will-love-you/

– El Bruno, nameof https://elbruno.com/2015/07/29/vs2015-c-6-nameof-operator-to-get-variables-types-or-members-names/

– MSDN Magazine, the new and improved C#6 https://msdn.microsoft.com/en-us/magazine/dn802602.aspx

Saludos @ Madrid

/El Bruno

One thought on “#VS2015 – C#6, using Expression Bodied Members … hell on earth !!!

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.