How can I hide a base class public property in the derived class

后端 未结 16 1590
自闭症患者
自闭症患者 2021-01-01 08:39

I want to hide the base public property(a data member) in my derived class:

class Program
{
    static void Main(string[] args)
    {
        b obj = new b()         


        
16条回答
  •  忘掉有多难
    2021-01-01 09:15

    First of all this is not good idea if you using some methods, that operates base class.
    You can try to use obsolete argument to make users twice think to use this property.

    [System.Obsolete("Do not use this property",true)]  
    public override YourType YourProperty { get; set; }
    

提交回复
热议问题