2018-08-30

Using the New Features in the Latest Versions of C#

The current version of Visual Studio 2017 (15.8.2 the day this is posted) actually supports C# version 7.3. You can see the new features by looking at the C# feature list. However, by default, Visual Studio will use C# version 7.0. To use versions after 7.0, you will need to go to the project properties, select Build, then click the Advanced button. In the dialog is a setting for Language Version. Changing this to 7.3, for example, will enable the latest features.

You can use this same setting for turning off features. If you don't like the stuff they added to C# version 7, you can go back to 6, or even back to 3. They have been pretty good, however, at not screwing up the language with features added in later versions. I can't think of a feature where I went, "I wish they didn't put that in the language." I think lambda expressions are overused by a lot of people, but there are places where they are appropriate. I also use "var" as little as possible, but there are places where var is necessary and useful. The usage of these features is a coding style issue, not a problem with the language itself.

You can see the features that might be coming in future versions of C# at this page. The biggest feature that is being discussed is non-nullable reference types. With these, you can specify that a specific reference type cannot ever be null. This will likely change how a lot of C# code gets written.

No comments :

Post a Comment

Note: Only a member of this blog may post a comment.