LZ  的表达有问题,你说的 构造函数?
   构造函数 在初始化的时候 就调用了。  classA a=new classA()  这个时候就调用了 classA  的构造函数了啊。

解决方案 »

  1.   

    classA a=new classA() 
    classA a=new classA(参数1) 
    classA a=new classA(参数1,参数2) 
    .....
    不知道对不对了。
      

  2.   

    构造函数的访问修饰符是public,我们不能像调用私有方法那样直接调用;而它也不是static静态方法,所以也不能通过类名.方法名的方式来调用;如果作为一个普通公有的方法调用的话,需要创建类的实例,而创建类的实例需要执行构造函数,而其本身就是个构造函数,这就陷入了一个循环。Class Test
      {
        // 带参构造函数
        public Test(int i)
        {
          Console.WriteLine(i);
        }
        // 无参数的构造函数
        public Test() : Test(0)
        {
          // 看到了吗,这里是不能调用的,调用要放到上面写
        }
      }答案很明了,希望对你有帮助!
      

  3.   

    当类中的一个方法名与类名相同时,C#即认为此方法为类的构造方法。
    一个类中可以存在多个构造方法,以不同的参数进行区分,这就构成了构造方法的重载
    public class Sample {
    private int x;
    public Sample() { // 不带参数的构造方法}
    public Sample(int x) { //带参数的构造方法
    this.x=x;
    }
    构造方法只能通过以下方式被调用:
    当前类的其他构造方法通过this语句调用它。
    当前类的子类的构造方法通过super语句调用它。
    在程序中通过new语句调用它
      

  4.   

    在你实例化类对象的时候调用如2楼所说
    classA a=new classA() 
    classA a=new classA(参数1) 
    classA a=new classA(参数1,参数2) 
    第一个调用的就是无参数的
    第二三个就是调用有参数的构造函数。
      

  5.   

    无参的构造方法和有参的构造方法在哪个时候用呀!!!! 无参的构造函数,是系统默认的,你生成了一个类就会有,有参的构造函数class Person
    {
       private string name;
    private int age;
        public Person(){}
       public Person(string name,int age)
    {
       this.name=name;
    this.age=age;
    }
    }