mardi 14 août 2018

Cannot convert type Attribute to MyAttribute

I am developing a c# app and trying to get attribute of my class and according to that link https://docs.microsoft.com/en-us/dotnet/standard/attributes/retrieving-information-stored-in-attributes my code is:

Type myType = typeof(MyClass)

MyAttribute myAttribute = (MyAttribute)Attribute.GetCustomAttribute(myType, typeof (MyAttribute)); That line, I get this error message "Cannot convert type Attribute to MyAttribute". I don't understand what the problem is. Anyone can help me?





Aucun commentaire:

Enregistrer un commentaire