31 July 2018
Since the first release of .NET (in 2002) much has changed, both in the .NET Framework and the .NET languages. Notable language features added over the years include support for Generics and Lambdas. In terms of languages usage C# appears to be gaining dominance compared to VB.NET, although resulting in some organisations needing to port to C# as VB.NET developers become more scarce. In recent years there have been smaller, but important additions to the C# languages. The notably C# 6 feature of 'string interpolation' has made creating strings so much easier.
Meanwhile C# 7 has added features like ‘pattern matching’ potentially allowing simplification of various conditional code.
The proposed C# 8 features will add a whole new set of ‘improvements’.
Helping to resolving a problem within the languages which has been there from the start is a features to reduce the risk of ‘NullReferenceException’. This was potentially a common exception as attempts to use members of a reference variable initialised to null would produce this exception. Helping to prevent having reference variables with the value of ‘null’ will be useful!
Record types look to be a major time saving feature, with the ability to define a ‘value’ by simply providing named properties and allowing all of the ‘standard’ boiler plate code to be generated automatically.
However, another addition which could be a major time saving (and
simplifying) feature is that of ‘Range’. Other languages have supported this type of feature for some time and so C# may soon get this feature too. It will be nice to be able to write 2…5 to define a range.
For many years there has been increasing emphasis on async working, especially with the introduction of the simplifying language features of ‘async and await’ and so now C# 8 may add the hybrid feature of asynchronous streams. Thus more code will be amenable to asynchronous working.
Whilst this has been just a brief introduction to some of the new features, it should be obvious that these additions could have significant impact on the writing C# code in the future.
Take a look at our C# and .NET courses for more information.