Jules
Jules

Reputation: 4339

Strange Property Override in DataGridViewTextBoxCell

If you look at the DataGridViewTextBoxCell property, ValueType, in reflector, you can see it overrides a property from DataGridViewCell.

The strange thing is, is that the overriden property is readonly, but the property in the parent class is read and write.

I can only presume that the property has been shadowed and reflector doesn't ...erm .. reflect this.

Is this right?

eta: I'm looking at the source, in reflector, as vb.net.

Upvotes: 0

Views: 182

Answers (1)

Alfred Myers
Alfred Myers

Reputation: 6453

The CLR implements properties internally as methods. There will be one method for each acessor. So if your property is read/write, you will have two methods. If your method is read-only or write-only, then you will have only one method.

You can see that for yourself using Reflector if you choose IL instead of Visual Basic.


.method public hidebysig specialname virtual instance class [mscorlib]System.Type get_ValueType() cil managed

If you comapre with the ToString method...


.method public hidebysig virtual instance string ToString() cil managed

... you will note that both start with ".method".

Since you have two methods, you can override them independently one from another.

Upvotes: 1

Related Questions