Suppose I have this class:
class MyClass {
public int MyProperty { get; set; }
}
And I want to get the MyProperty as string (e.g. "MyProperty") but through lambda expression or any other way that is "refactoring-friendly".
Is there a syntax that is something like this:
void BindToDataSource(IEnumerable<MyClass> list) {
myComboBox.DataSource = list;
myComboBox.DisplayMember = typeof(MyClass).GetPropertyToString(c => c.MyProperty);
}
I dont want to this code:
myComboBox.DisplayMember = "MyProperty"
because it is not "refactoring-friendly".