Posts

Showing posts from September, 2017

C# 8 Preview

I recently watched the preview of C#8 with Mads Torgersen and Seth Juarez ( here ). I would recommend giving it a watch. But if you don't have time I've written a summary of the new features they talked about in this article.  (It's probably important to say C#8 is still in the planning stages, so some of these features may change) Nullable Reference Types We are all familiar with nullable value types in C#. At the moment you can declare a type as either int or int? (for example). The int type cannot be null and if you want to use the int? type as an int (i.e. get the value of it) its up to you to perform the necessary checks on the value that it isn't null. However, for reference types, there is currently no such thing as a "nullable reference type". Creating all those "null reference exceptions" in our production system we hate. For exampe: string s = null; int len = s.Length; is valid C# but will produce a runtime error. Well, ...