I am using Reflection to check if a property exists and get the value.
It is working fine when there is a value in that property. But "GetValue" is throwing an exception "Object reference not set to instance of an object" when there is no value.
How can I make sure it does not throw exception if there is no value. It looks like I need to check some other property before invoking GetValue. Thanks for any help.
PropertyInfo info = null;
info = Parties[i - 1].GetType().GetProperty(partyfield.Node);
if (info != null)
fieldvalue = info.GetValue(Parties[i - 1], null).ToString();