I want to access the properties of a class from the attribute class by using reflection. Is it possible?
For example:
class MyAttribute : Attribute
{
private void AccessTargetClass()
{
// Do some operations
}
}
[MyAttribute]
class TargetClass
{
}
Not directly, but in order for the attribute to do anything, you already must have a handle to the type/member and call its
GetCustomAttributesmethod, so you can simply pass it in from there:Using it like so: