nameof Interpreter will be resolved in compiletime and translated instead of static string .
In your case, nameof(TestClass.Name) you will return "Name" only as a string.
You should use nameof(TestClass) .
With nameof you can minimize redundancy in your code (for example: you donβt need to define a string for the property name or something like that with nameof .
You can also use it to represent the name of classes. But keep in mind! nameof(MyClass)
may not be the same as at runtime if you have a derived class! For execution purposes, use typeOf or .GetType() instead.
More on MSDN
source share