What's the difference between an abstract class and a static one?

后端 未结 9 1910
臣服心动
臣服心动 2020-12-02 18:55

Neither is instantiable. What are the differences, and in what situations might you use one or the other?

9条回答
  •  既然无缘
    2020-12-02 19:07

    Main difference between the two is extensibility.

    CLR marks all 'static' classes as 'abstract & sealed' behind the scene (i.e., they cannot be inherited hence cannot be extended) and .NET Framework CLR loads them automatically when containing program or namespace is loaded. This gives performance gain on runtime.

    Philosophy behind 'abstract' classes is capitalizing all common features of all extended classes in one place.

    Hope it helps.

提交回复
热议问题