4 ms·
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/va
by Townley 2y 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
- yyyk 2y agonameof() is a compile time method, not a runtime method like most dynamic language equivalents.
- 8n4vidtmkvmk 2y agoName of! Never knew this existed. I think it would make writing some debug statements easier and immune to renames.
- zahlman 2y agoInteresting, but it isn't causing the value (here, the "bar" string object) to know about that name.