Why is overriding static method alowed in C#

前端 未结 6 1178
陌清茗
陌清茗 2021-02-06 06:55
protected static new void WhyIsThisValidCode()
{
}

Why are you allowed to override static methods? Nothing but bugs can come from it, it doensn\'t work

6条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-06 07:34

    The new keyword does not override a method. It instead creates a new method of the same name which is independent of the original. It is not possible to override a static method because they are not virtual

提交回复
热议问题