I want to use nameof in order to get the name of a property.
The following work:
DerivedClass EC = baseClassObj as DerivedClass;
nameof(EC.propertyX)
but this doesn't work:
nameof((baseClassObj as DerivedClass).propertyX)
with the compile error of:
Sub-expression cannot be used in an argument to nameof
BTW, also this doesn't work:
nameof(((baseClassObj)DerivedClass).propertyX)
Can someone explain this casting + nameof problem?