Determine if a property is read-only, write-only or read-write with reflection

  • Thread starter Thread starter darin_dimitrov
  • Start date Start date
D

darin_dimitrov

Is it possible to determine if a property is read-only, write-only or
read-write with reflection? Does MemberInfo class contains such
information?

Thanks
 
Is it possible to determine if a property is read-only, write-only or
read-write with reflection? Does MemberInfo class contains such
information?

Not MemberInfo but the derived PropertyInfo class does. If you have a
MemberInfo object reference for a property it should actually be a
PropertyInfo so try to cast it. Then check the CanRead and CanWrite
properties.


Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top