How to

get member's custom attributes

Published: 18. December 2008 | Updated: 9. October 2011
License: Microsoft Public License (MS-PL)
Categories: Framework » Attributes, Framework » Reflection
Tags: Attributes C# Reflection
Was this snippet helpful for you? YESYES / NONO

Import namespace

using System.Reflection;

Code

MemberInfo info = typeof(MyProgram).GetMethod("Test");
object[] attributes = info.GetCustomAttributes(true);

foreach (object obj in attributes)
{
    Console.WriteLine(obj);
}
Send us feedback about this snippet »



Related Snippets: