CSharp examples for System.Reflection:Attribute
Get Custom Attributes
// Copyright (c) Microsoft Corporation. All rights reserved. using System.Runtime.CompilerServices; using System.Reflection; using System.Linq; using System.Collections.Generic; public class Main{ internal static IEnumerable<T> GetCustomAttributes<T>(this Type type, bool inherit) where T : Attribute {/*from w w w. j ava2 s . co m*/ return from attr in type.GetCustomAttributes(typeof(T), inherit) where attr is T select (T)attr; } }