\"nameof\" expression is introduced in Visual Studio 2015 and c# 6
nameof (C# and Visual Basic Reference)
How can u use it or write a similar method in older
@Rob, thank you so much, but the static member access could be for the non-static class members too.
public static class TestExtension {
public static String nameof(this Expression> accessor)
{
return nameof(accessor.Body);
}
}
class MyClass {
public Guid MyOtherField;
}
TestExtension.nameof(o=>o.MyOtherField);
and the good news is the Class won't be instantiated. It is useful to access domain layer DTOs.