Hiding inherited members

前端 未结 9 1919
北海茫月
北海茫月 2020-12-03 09:52

I\'m looking for some way to effectively hide inherited members. I have a library of classes which inherit from common base classes. Some of the more recent descendant clas

9条回答
  •  温柔的废话
    2020-12-03 10:01

    I tested all of the proposed solutions and they do not really hide new members.

    But this one DOES:

    [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
    public new string MyHiddenProperty
    { 
        get { return _myHiddenProperty; }
    }
    

    But in code-behide it's still accessible, so add as well Obsolete Attribute

    [Obsolete("This property is not supported in this class", true)]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
    public new string MyHiddenProperty
    { 
        get { return _myHiddenProperty; }
    }
    

提交回复
热议问题