C#static class为什么使用? [英] C# static class why use?

查看:145
本文介绍了C#static class为什么使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

何时在C#中使用静态类

我将我的类设置为静态,但是我不确定什么时候使用静态,或者使用它是否有什么不同。

I set my classes as static a lot, but I am not sure when use static or not, or what's the difference it makes to use it or not.

推荐答案

让类静态只是阻止人们试图创建一个实例。如果所有的类都是静态成员,这是一个很好的做法,使类本身是静态的。

Making a class static just prevents people from trying to make an instance of it. If all your class has are static members it is a good practice to make the class itself static.

这篇关于C#static class为什么使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆