New in C# 7.0: Part 4 – Expression-Bodied Members

This week, we’re discussing Expression-Bodied Members in C# 7.0. Now, this was an existing feature in C# 6.0, but it was limited to only methods, like so:

With the new additions in C# 7.0, we can now do Constructors, Deconstructors, and Properties. A Constructor definition looks like this:

Similarly, a Deconstructor looks like this:

Finally, although auto-properties are shorter, you can write properties with specific implementations with this new shorthand:

That’s it for this week. Next week, we’ll go over Pattern Matching.

Leave a Reply

Your email address will not be published. Required fields are marked *