关于静态类在c# [英] Regarding Static class in c#

查看:107
本文介绍了关于静态类在c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
何时使用静态类在C#

为什么会有人写一个静态类。我们可以宣布任何类的静态方法,并调用而无需创建类的实例方法。所以请告诉我,在什么样的情况的人士将创建一个静态类,也告诉我什么是静态类和普通类之间的主要差别。

why anyone would write a static class. we can declare a static method in any class and just call that method without creating class instance. so please tell me in what type of situation a person would create a static class and also tell me what are the main differences between static class and normal class.

感谢

推荐答案

一个静态类不能被实例化。它的主要用途是要清楚的类没有实例方法和阻止人们意外地试图新之类的。

A static class cannot be instantiated. It's main uses are to make it clear that the class has no instance methods and to prevent people from accidentally trying to "new" the class.

这篇关于关于静态类在c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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