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

后端 未结 16 1507
自闭症患者
自闭症患者 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:02

    You could use interfaces to hide the property. The child class would implemented an interface that didn't have the property then it wouldn't appear.

    You would need two interfaces for when you want the property and when you don't, thus making it a horrible hack.

提交回复
热议问题