Get Attribute from Method - CSharp System

CSharp examples for System:Attribute

Description

Get Attribute from Method

Demo Code


using System.Linq;
using System.Reflection;
using System.Collections.Generic;

public class Main{
        public static T GetAttribute<T>(this MemberInfo memberInfo, bool inherit = false)
        {//from   w ww  . ja  v  a  2s  .c  o  m
            return memberInfo
                .GetAttributes<T>(inherit)
                .SingleOrDefault();
        }
}

Related Tutorials