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
 
Back
Top