C# Feature β nameof
Overview
Section titled βOverviewβThe nameof operator returns the unqualified string name of a symbol at compile time. Safer than magic strings.
Introduced In
Section titled βIntroduced InβC# 6 (2015)
throw new ArgumentNullException("userName");throw new ArgumentNullException(nameof(userName));Gotchas & Best Practices
Section titled βGotchas & Best Practicesβnameof(Type.Member)returns just βMemberβ. Use for argument names, property changed events, logging, and mapping.