Click here to Skip to main content
13,148,214 members (52,912 online)
Click here to Skip to main content
Articles » Languages » C# » General » Alternatives
Alternatives (2)
Add your own
alternative version

Tagged as


2 bookmarked
Posted 14 Apr 2010

Get CustomAttributes the easy way....

, 16 Apr 2010
A few extension methods to help out.....// Project: Salient.Reflection// http://salient.codeplex.comusing System;using System.Collections.Generic;using System.Linq;using System.Reflection;public static class AttributeHelpers{ /// /// Returns first...


Members may post updates or alternatives to this current article in order to show different approaches or add new features.

15 Apr 2010
Wouter Ballet
I have a similar set of extension methods, but instead of MemberInfo, I used ICustomAttributeProvider, which is a more general approach as MemberInfo implements this interface. This would make the extensions usable on the types Assembly and Module to name just a few...Regards,Wouter
15 Apr 2010
How about typing the 'this' parameter as ICustomAttributeProvider ?Also, ToList(...).Where(...) is bad Linq usage, becauseToList() triggers enumeration of the sequence. Try Where(...).ToList() instead.And the ToList() in 'ToList().FirstOrDefault(...)' is entirely pointless.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Sky Sanders
Software Developer (Senior) Salient Solutions
United States United States
My name is Sky Sanders and I am an end-to-end, front-to-back software solutions architect with more than 20 years experience in IT infrastructure and software development, the last 10 years being focused primarily on the Microsoft .NET platform.

My motto is 'I solve problems.' and I am currently available for hire.

I can be contacted at

| | Privacy | Terms of Use | Mobile
Web02 | 2.8.170924.2 | Last Updated 16 Apr 2010
Article Copyright 2010 by Sky Sanders
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid