What if I don't heed the warning “hides inherited member. To make the current member override that implementation…”

前端 未结 3 1283
既然无缘
既然无缘 2021-02-02 07:36

This is maybe a fine point, but it concerns the warning that the compiler issues if you do something like:

class A
{
    public virtual void F() { }
}
class B :          


        
3条回答
  •  北荒
    北荒 (楼主)
    2021-02-02 08:18

    This is just warning. Code will work. In some circumstance, this warning can lead to some problem.

    use new keyword with the method which you are calling from the base class.

    class A
    {
        public virtual void F() { }
    }
    class B : A
    {
       new public void F() { }
    }
    

    Reference

    https://msdn.microsoft.com/en-us/library/435f1dw2.aspx

    https://msdn.microsoft.com/en-us/library/aa691135(v=vs.71).aspx

提交回复
热议问题