CSharp examples for System.Reflection:PropertyInfo
Get Property from Object
using System.Text; using System.Reflection; using System;/*from w ww . j a v a2 s . c o m*/ public class Main{ public static object GetProperty(this object obj, string name) { var propertyInfo = obj.GetType().GetProperty(name, BindingFlags.GetProperty | BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); return propertyInfo == null ? null : propertyInfo.GetValue(obj, null); } }