Get Property - CSharp System.Reflection

CSharp examples for System.Reflection:PropertyInfo

Description

Get Property

Demo Code


using System.Reflection;
using System.Linq;
using System.Collections.Generic;
using System;/*from  ww  w. j  a  v a  2s  . c o  m*/

public class Main{
        public static PropertyInfo GetProperty(this Type type, string name)
        {
            return type.GetTypeInfo().DeclaredProperties.FirstOrDefault(p => p.Name == name);
        }
}

Related Tutorials