top | item 43227377

(no title)

Townley | 1 year ago

In C# you can do

string foo = "bar";

string nameOfFoo = nameof(foo); // “foo”

Kinda nice for iterating through lists of variables and saving them to a key/value map

discuss

order

yyyk|1 year ago

nameof() is a compile time method, not a runtime method like most dynamic language equivalents.

zahlman|1 year ago

Interesting, but it isn't causing the value (here, the "bar" string object) to know about that name.

8n4vidtmkvmk|1 year ago

Name of! Never knew this existed. I think it would make writing some debug statements easier and immune to renames.