Open daveyostcom opened 1 year ago
The page linked does not help to clarify.
Are you refering to Nameof?
The benefit of nameof
is that you can "reference" a symbol in the source, and if you rename that symbol, then nameof
will use the new value. So no magic strings, no latent errors by forgotten updates of these magic strings, and so on.
In the docs for nameof
there's
This is useful in various scenarios, such as logging, and protects your logging against changes in source code.
under Remarks, but this could be more prominent and w/o the example of logging given?
tagging @vzarytovskii for recommendation on the best fix.
Are you refering to Nameof?
Yes
The benefit of
nameof
is that you can "reference" a symbol in the source, and if you rename that symbol, thennameof
will use the new value. So no magic strings, no latent errors by forgotten updates of these magic strings, and so on.
That’s a nice way to put it.
In the docs for
nameof
there'sThis is useful in various scenarios, such as logging, and protects your logging against changes in source code.
under Remarks, but this could be more prominent and w/o the example of logging given?
It would be compelling to explain as above and also give a logging example.
A compelling use for the
nameof
pattern is not presented. I can’t see the usefulness from the example given.seems to work identically to this:
The page linked does not help to clarify.
Document Details
⚠ Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.