Object Extension Methods

IEnumerable<T> Attributes<T>()
Gets a collection of attributes(of a certain type) found on a type.
public class MyCustomClass

[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
public class MyCustomAttribute : Attribute

// given the setup above and used in some method like:
MyCustomClass instance = new MyCustomClass();
var attributes = instance.Attributes<MyCustomAttribute>();

Last edited Feb 20, 2010 at 9:37 AM by jole, version 1


No comments yet.