c# 一个关于类的简单问题
class   c 
 { 
             private   c() 
             { 
             } 
 }   
 里面这个private   c有是什么,有什么作用?
------解决方案--------------------私有构造函数是一种特殊的实例构造函数。它通常用在只包含静态成员的类中。如果类具有一个或多个私有构造函数而没有公共构造函数,则不允许其他类(除了嵌套类)创建该类的实例。例如:   
 class NLog   
 {   
     // Private Constructor:   
     private NLog() { }    public static double e = System.Math.E;  //2.71828...   
 }   
 声明空构造函数可阻止自动生成默认构造函数。注意,如果您不对构造函数使用访问修饰符,则在默认情况下它仍为私有构造函数。但是,通常显式地使用 private 修饰符来清楚地表明该类不能被实例化。   
 当没有实例字段或实例方法(如 Math 类)时或者当调用方法以获得类的实例时,私有构造函数可用于阻止创建类的实例。如果类中的所有方法都是静态的,可考虑使整个类成为静态的。有关更多信息,请参见静态类和静态类成员。   
 示例   
 下面是使用私有构造函数的类的示例。   
 public class Counter   
 {   
     private Counter() { }   
     public static int currentCount;   
     public static int IncrementCount()   
     {   
         return ++currentCount;   
     }   
 }   
 class TestCounter   
 {   
     static void Main()   
     {   
         // If you uncomment the following statement, it will generate   
         // an error because the constructor is inaccessible:   
         // Counter aCounter = new Counter();   // Error        Counter.currentCount = 100;   
         Counter.IncrementCount();   
         System.Console.WriteLine( "New count: {0} ", Counter.currentCount);   
     }   
 }   
 输出   
 New count: 101   
 注意,如果您取消注释该示例中的以下语句,它将生成一个错误,因为该构造函数受其保护级别的限制而不可访问:   
 // Counter aCounter = new Counter();   // Error