0

This one is pretty straightforward, I have nameof(Product.#whatever#) statements thorough my app to prevent typos, get intellisense and ease refactoring. I need something like nameof(Product.PricePerUnit.Value) that would return "PricePerUnit.Value" instead of "Value", while keeping all the pros I mentioned.

Luk164
  • 657
  • 8
  • 22
  • 3
    Scope depends on the eye of the beholder, `nameof` does not. To get something like that you'll have to cobble it together yourself, a la `$"(nameof(Product.PricePerUnit)}.{nameof(Product.PricePerUnit.Value)}"`. – Jeroen Mostert Nov 12 '20 at 20:20
  • 2
    [#3100](https://github.com/dotnet/csharplang/issues/3100) and [#373](https://github.com/dotnet/csharplang/issues/373) proposal – Pavel Anikhouski Nov 12 '20 at 20:24
  • 1
    take a look at this answer - https://stackoverflow.com/questions/27898178/why-does-nameof-return-only-last-name – Mario Sandoval Nov 12 '20 at 20:27
  • Cobbling together it is then... – Luk164 Nov 12 '20 at 20:39

0 Answers0