Refactoring old C#5 code to C#6 code

Categories C# Coding Techniques

This post is not the usual one. I wanted to show you how it looks and feels refactoring and improving old C# 5 code using features of C# 6. Doing it in the traditional way by simply writing and giving code snippets is not very productive and I have decided to try out other media – actually doing a screencast. I have done it for the first time and therefore quality is not as good as you might want, but I promise to do it better in the future.
Regarding C# 6 I would like to point out that its most features are about making the code more succinct and terse and feel like functional. And since functional programming paradigm is taking over the programming world, I believe it is a very good move for C#.

Features, which I apply in the video:

  • Expression Bodied Methods/Properties
  • Null propagation
  • Auto-Property Initializers
  • Using static members
  • String Interpolation
  • Operator nameof
  • Dictionary Initializer
  • Exception Filters

If you like what I do in the video and you would like to play with this code yourself, then go to my GitHub repository, check the old code out and do some C#6 refactoring. Visual Studio 2015 community edition is just fine for this.


Leave a Reply

Your email address will not be published.