For Microsoft Kool-Aid Drinkers, Non-paid MS Evangelists written by a Senior Consultant, Passionate about Tech

C# 6.0 Tips and Tricks: Auto Property Initializer

C# 6.0

A simple, yet time consuming aspect of developing in C# is creating property initializers.  I know, you are a wizard with typing, or even using code snippets.  However, C# 6.0 just made it even more simple.

So, if you were to code up a property initializer by hand, it would look something like this in C# 5.0:

No Auto Initializer

You will notice above that we have to initialize the properties in the constructor.  Well, check this out, with C#6.0, we can do it all on one line:

Auto Initializer

Pretty awesome huh?  Saves some time for sure.  Now, add your keyboard shortcut to creating properties, using the prop snippet, and time will stand still.

I hope you enjoyed this post.  If so, please share it with others!  Keep your eyes posted for more C# Tips and Tricks coming soon…

 
Comments
 
Comments

No comments yet.

Leave a Reply

You must be logged in to post a comment.