reflection - How can I read attributes of a class in an external dll file in c#? -


i have following block of code. how can attribute names specific dll file? currently, can class names, namespace not know how attributes in class. thank you,

foreach (type type in myassambly.gettypes()) {     propertyinfo mypi = type.getproperty("defaultmodifiers");     system.reflection.propertyattributes mypa = mypi.attributes;      messagebox.show(mypa.tostring()); } 

it sounds you're interested in properties:

foreach (type type in myassembly.gettypes()) {     foreach (propertyinfo property in type.getproperties())     {         messagebox.show(property.name + " - " + property.propertytype);     } } 

edit: okay, sounds really really want fields:

foreach (type type in myassembly.gettypes()) {     foreach (fieldinfo field in type.getfields(bindingflags.instance |                                                 bindingflags.static |                                                bindingflags.public |                                                bindingflags.nonpublic))     {         messagebox.show(field.name + " - " + field.fieldtype);     } } 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -