Link to home
Start Free TrialLog in
Avatar of ipjyo
ipjyoFlag for United States of America

asked on

How to check if a property exists on an object and get the value of that property using reflection?

hi,

I need to check if a property exists on an object and get the value of that property if the property exists.
I have the attached code.
Thanks for any suggestions.



PropertyInfo info;

		            foreach (Field FO in section.FOCollection)
                    {
                        info = Myobj.GetType().GetProperty(FO.Node);
                        
                    }


if(info!=null)
{
 //get the value
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs)
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ipjyo

ASKER

Thank you.