I have a class Person that has custom attributes (Header).
[AttributeUsage(AttributeTargets.Property)]
public class Header : Attribute
{
public string Name { get; set; }
}
public class Person
{
[Header(Name = "First Name")]
public string FirstName { get; set; }
[Header(Name = "Last Name")]
public string LastName { get; set; }
public Person(string first, string last)
{
FirstName = first;
LastName = last;
}
}
I want to create a method that can return all attributes of an object in a list
Person person = new Person("first", "last");
//List<string> attributes = GetAttributes(person);
// output:
// - "First Name", "Last Name"