我遇到过一个非静态的类,但所有的方法和变量都是静态的.例如:
public class Class1 {
private static string String1 = "one";
private static string String2 = "two";
public static void PrintStrings(string str1, string str2)
{
...
Run Code Online (Sandbox Code Playgroud)
所有变量在所有实例中都是静态的,因此没有必要具有类的单独实例.
有没有理由创建这样的类?
Mat*_*ton 17
该课程是在.NET 1.x天内写回来的吗?静态类直到C#2.0才出现.
| 归档时间: |
|
| 查看次数: |
997 次 |
| 最近记录: |