C
Charles Bazi
Hi, I have a class with custom attributes.
Aka [MyAttribute( "Joe")]
I try to get value of my attribute, but inside the class where it's
declared with this piece of code:
string _ClassType = string.Empty;
Type _object = Type.GetType( this.GetType().ToString() );
object[] _AttributeMine = _object.GetCustomAttributes( typeof(
MyAttribute ), true );
if(_AttributeMine.Length == 1) {
_ClassType = ( _AttributeMine[0] as MyAttribute ).Name;
}
After debugging, I see _object being assigned with my class'type,
AttributeMine is null after trying to load it with :
_object.GetCustomAttributes( typeof( MyAttribute ), true );
Is this a normal behaviour ?
Thank you
Aka [MyAttribute( "Joe")]
I try to get value of my attribute, but inside the class where it's
declared with this piece of code:
string _ClassType = string.Empty;
Type _object = Type.GetType( this.GetType().ToString() );
object[] _AttributeMine = _object.GetCustomAttributes( typeof(
MyAttribute ), true );
if(_AttributeMine.Length == 1) {
_ClassType = ( _AttributeMine[0] as MyAttribute ).Name;
}
After debugging, I see _object being assigned with my class'type,
AttributeMine is null after trying to load it with :
_object.GetCustomAttributes( typeof( MyAttribute ), true );
Is this a normal behaviour ?
Thank you