mardi 12 novembre 2019

How to get internal attribute from type?

I have a class:

[DefiniteAttribute]
public class SomeClass
{
}

Definition of DefiniteAttribute:

internal class DefiniteAttribute : Attribute
{
}

I want to get attribute DefiniteAttribute from my class. But I failed, variable definiteAttribute is null

var definiteAttribute = (DefiniteAttribute) typeof(SomeClass).GetCustomAttribute(typeof(DefiniteAttribute), false);

Tell me please, how should I write the code in order to get internal attribute from type?





Aucun commentaire:

Enregistrer un commentaire