I would like to determine if an object has a property specified. The value of the property can be null or any value, I just need the key to be there. My attempts so far have been using reflection, but this didn't help:
var t = typeof(MyObject);
PropertyInfo p = t.GetProperty("myProperty");
if (p == null)
{
//property does not exist
return false;
}
return true;
The problem here is that the value of the field is null, it returns false to me. I just want to be able to detect that the property is present. Thank you!