Hacker News new | ask | show | jobs
by ppog 4176 days ago
It's resolved at compile time. It's exactly equivalent to the literal "x", but enables refactoring tools to pick up renames, compilers to error if the name is typoed, etc.
1 comments

I've always wondered why a feature with so much benefits and such low implementation overhead has not been implemented a long time ago.
There are many edge cases you need to consider, so a seemingly simple language feature can become hard to get right quickly.

I highly recommend reading through https://roslyn.codeplex.com/discussions/570551 and the other four revisions of the nameof() spec, they do a very good job at explaining the tradeoffs of each design.