var someObject = new SomeClass();
var someType = someObject.GetType();
MemberInfo[] objMember = someType.GetMembers();
foreach (MemberInfo m in objMember)
Attribute[] attributes = Attribute.GetCustomAttributes(someType);
foreach (Attribute attribute in attributes)
if (attribute is SomeAttribute someAttribute)
Console.WriteLine($"Some attribute value: {someAttribute.SomeValue}");
[AttributeUsage(AttributeTargets.Class)]
class SomeAttribute : Attribute
public SomeAttribute(string someValue)
this.SomeValue = someValue;
public string SomeValue { get; set; }
private string someField;
public int SomeProperty { get; set; }
public void SomeMethod(int someParameter)
this.SomeProperty = someParameter;