C# static member “inheritance” - why does this exist at all?

前端 未结 7 1419
忘掉有多难
忘掉有多难 2020-11-27 19:32

In C#, a superclass\'s static members are \"inherited\" into the subclasses scope. For instance:

class A { public static int M() { return 1; } }
class B : A         


        
7条回答
  •  南笙
    南笙 (楼主)
    2020-11-27 19:46

    I rather have access to all my based static members in derived classes. Otherwise i would need to know exactly where the static member was defined and call it explicitly.

    When using Intellisense you can automatically know every static member available to that kind of class.

    Of course, they are not inherited, it's just a shortcut

提交回复
热议问题