<p>There has been a lot of sentiment to include a <code>nameof</code> operator in C#. As an example of how this operator would work, <code>nameof(Customer.Name)</code> would return the string <code>"Name"</code>.</p>

<p>I have a domain object. And I have to bind it. And I need names of properties as strings then. And I want them to be type-safe.</p>

<p>I remember coming across a workaround in .NET 3.5 which provided the functionality of <code>nameof</code> and involved lambda expressions. However, I have not been able to locate this workaround. Can anyone provide that workaround to me?</p>

<p>I am also interested in a way to implement the functionality of <code>nameof</code> in .NET 2.0 if that is possible.</p>

The workaround is to use an expression tree, and to take that expression tree apart to find the relevant
```
MemberInfo
```
. There's slightly more detail and comment in
this note
(although not the code to pull out the member - that's in another SO question somewhere, I believe).
Unfortunately as expression trees don't exist in .NET 2.0, there's really no equivalent.
One solution to avoid typos is to have a set of accessors which fetch the relevant
```
PropertyInfo
```
for a particular property, and unit test them. That would be the only place which had the string in it. This would avoid duplication and make refactoring easier, but it's a bit draconian.