Fragrance
|
C# 6.0 is the new version which will be shipped with Visual Studio 2015 and with new version Microsoft came up with lot many features. So if you haven't tried the new IDE, download the preview version and you can enjoy all the new features which will be coming in the release. Below are some of the features : Today we will learn about the new feature called "nameof" expression which will help developers solve the problem while coding with Properties and Notifications. Often Developer requires to provide the string that names which names some program element while throwing the exception and even Developer face issues with the hard coded string literals when passing as a parameter to Property Change event handler. Using string literal is simple but its highly error prone and there are high chances that Developer may spell it wrong. Prior to C# 6.0 it was : But now Developers don't have to specify any string literals and the savior for them is the keyword named "nameof" which developer can use to create the expression to specify the name. So the above code will change as below : private CountryBO _country; But now Developers don't have to specify any string literals and the savior for them is the keyword named "nameof" which developer can use to create the expression to specify the name. So the above code will change as below : private CountryBO _country; Thus "nameof(Country)" will return string literal "Country". Hope you like the features.
In my next post I will explore more of the C# 6.0 features which will be helpful to the Developers. Happy Coding. Rishi
Comments
|
Categories
All
Archives
May 2020
|