When to use static classes and methods?

前端 未结 4 810
离开以前
离开以前 2021-01-12 13:10

I have a general question...when should i be using static classes or static methods?.. I know the idea that static methods can be called without instantiating...and static c

4条回答
  •  悲&欢浪女
    2021-01-12 14:12

    As I understand it that's when there's no sense to create an object of a class to invoke an action or that class is common within the application. For example, in C#, Console class is sealed (so you can't create an object and inherit it, and there's really no sense to do it). But professionals will explain you better, however.

提交回复
热议问题