C# Get memberinfo for custom attribute's target
- by Waldo Bronchart
Given a custom attribute, I want to get the name of its target:
public class Example
{
[Woop] ////// basically I want to get "Size" datamember name from the attribute
public float Size;
}
public class Tester
{
public static void Main()
{
Type type = typeof(Example);
object[] attributes = type.GetCustomAttributes(typeof(WoopAttribute), false);
foreach (var attribute in attributes)
{
// I have the attribute, but what is the name of it's target? (Example.Size)
attribute.GetTargetName(); //??
}
}
}
Hope it's clear!