静态类与仅具有静态方法的类(例如私有构造函数)有什么区别?
假设我们有:
using System;
public class Test
{
public static void Main()
{
Info.SetName("nnn");
Console.WriteLine(Info.Name);
Info.SetName("nn2");
Console.WriteLine(Info.Name);
Info2.SetName("nnn");
Console.WriteLine(Info2.Name);
Info2.SetName("nn2");
Console.WriteLine(Info2.Name);
}
}
public class Info
{
public static string Name;
public static void SetName(string name){
Name = name;
}
}
public static class Info2
{
public static string Name;
public static void SetName(string name){
Name = name;
}
}
那么从方法/属性访问性能、代码可读性、代码可扩展性的角度来看呢?