Has Attribute from a Type - CSharp System.Reflection

CSharp examples for System.Reflection:Type

Description

Has Attribute from a Type

Demo Code


using System.Reflection;
using System.Linq;
using System.Collections.Generic;
using System;//from   ww w .ja  v a 2s  .  c om

public class Main{
        public static bool HasAttribute<TAttribute>(this Type type)
        {
            return type.GetCustomAttributes(typeof(TAttribute), true).Any();
        }
}

Related Tutorials