Partially Overriding a Virtual Auto-Property in a Child Class

前端 未结 2 1201
名媛妹妹
名媛妹妹 2021-02-05 05:09

Time for a theoretical question I just ran across.

The following code is valid and compiles:

public class Parent
{
    public virtual object TestProperty         


        
2条回答
  •  南旧
    南旧 (楼主)
    2021-02-05 05:48

    Doesn't it make sense for a setter, though? If you partially override only the setter, that could be useful so that you can respond to that event, in addition to calling base.TestProperty = value, without having to bother with a boilerplate override of the getter as well.

提交回复
热议问题