View Single Post
  #2 (permalink)  
Old October 28th, 2005, 01:11 PM
jacob jacob is offline
Friend of Wrox
Join Date: Jun 2003
Location: Copenhagen, , Denmark.
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts

I found a way but I am not sure it is the easiest way or the most cost-effective way. Here is the solution I found...
using System;
using System.Reflection;

namespace Test
    public class MyCustomAttribute : Attribute
        public string item;

        public MyCustomAttribute()
            this.item = item;

    class MyClassWithTheAttributeApplied
        public static void SomeMethod()
            MemberInfo info = typeof(MyClassWithTheAttributeApplied);
            object[] o = info.GetCustomAttributes(true);
            foreach(object t in o)

    class MainClass
        static void Main(string[] args)
The above code will output myitemvalue. Please comment on the post if you know a better way to do this. Thanks.