Get Property Value - CSharp System.Reflection

CSharp examples for System.Reflection:PropertyInfo

Description

Get Property Value

Demo Code


using System.Reflection;
using System.Linq;
using System;//from   w w w.  ja  va2  s. com

public class Main{
        public static Object GetPropertyValue(Object entity,string propertyName)
        {
            PropertyInfo property= entity.GetType().GetProperty(propertyName);
            return property.GetValue(entity, null);
        }
}

Related Tutorials