How to determine the attached type from within a custom attribute?
问题 I have a custom attribute which can be assigned to a class, [FooAttribute] . What I would like to do, from within the attribute, is determine which type has actually used me. e.g. If I have: [FooAttribute] public class Bar { } In the code for FooAttribute, how can I determine it was Bar class that added me? I'm not specifically looking for the Bar type, I just want to set a friendly name using reflection. e.g. [FooAttribute(Name="MyFriendlyNameForThisClass")] public class Bar { } public class