I'm trying to read all attributes of a methode which contains more than one attribute of the same type like:
[field(Feld = "x86", Index = 1)]
[field(Feld = "x93", Index = 2)]
...
[field(Feld = "x107", Index = 9)]
public string Methodename() {}
Reading the Attribute like:
Attribute mAttr = Attribute.GetCustomAttribute
(methodInfo, typeof (fieldAttribute), false) as fieldAttribute;
This throwing an AmbiguousMatchException . How do i read more than one attribute?
Thank you
Use GetCustomAttributes instead of GetCustomAttribute :)
For example:
Attribute[] attributes = Attribute.GetCustomAttributes
(methodInfo, typeof (fieldAttribute), false);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.