I have a datagrid populated by a Linq query. When the focused row in the datagrid changes I need to set a variable equal to one of the properties in that object.
You can loop through the properties of an anonymous type like this:
var obj = new {someValue = "hello", otherValue = "world"};
foreach (var propertyInfo in obj.GetType().GetProperties() {
var name = propertyInfo.Name;
var value = propertyInfo.GetValue(obj, index: null);
...
}