nameof Expression - C# 6 Language New features

Sometimes, we face such situations where we have to write class property names instead of property values, at that time we have to write static string or use various property functions. Instead of writing a static string, Microsoft introduces the new feature nameof expression. You have to just use following code instead of static string.

Syntax

nameof(propertyname)

In example, I have class having name MyClass. I initialize it and call in Program class. In previous version of C# we have to write static string like Console.Writeline("name"). Now, If I want to change property name? This is worse situation where I have to find a static string in a whole project. At this time a new feature is more useful. Instead of using a static string we can use Console.Writeline(nameof(cls.name)). This would be a better approach when we have to change property name.

Conclusion: nameof expression will more helpful to those developers( just like me) whose clients dramatically ask for to change property names. And, I am pretty sure, name of expression will help to rid of static declaration of property names.