I agree to answer @Reed. However, if you really want to achieve this functionality, you can do this work:
string thing = "etc"; thing = new{thing}.GetName();
The GetName extension method GetName simply use reflection to grab the name of the first property from an anonymous object.
The only other way is to use a Lambda expression, but the code will definitely be a lot more complicated.
source share