I want to get the PropertyInfo for a specific property. I could use:
foreach(PropertyInfo p in typeof(MyObject).GetProperties())
{
if ( p.Name == "MyProperty") { return p }
}
But there must be a way to do something similar to
typeof(MyProperty) as PropertyInfo
Is there? Or am I stuck doing a type-unsafe string comparison?
Cheers.