直接用类名就行了或者this.ClassName(a,b)。

解决方案 »

  1.   

    to call an overloaded constructor, you need to use a syntax likepublic BuyPlanDetail(int dID) : this (....)consider to move the code in the second constructor into another method and call it in both constructors
      

  2.   

    用this不行吗??那就奇怪了,据我所知这个应该是没有问题的啊,等一下测试一下。
      

  3.   

    思归:其实我的类库是这么设计的
    Product类:为所有货物的基础类
    DetailBase类:为所有明细的基础类
    所有的实际明细,比如采购明细,出入库明细都从DetailBase继承,这里面就设计一个建构函数多级继承的问题。
    class Product
    {
       public Product(){}
       public Product(int productID){.....}
    }
    class DetailBase:Product
    {
       public DetailBase():base()
       public DetailBase(int productID):base(productID){.....}
    }class BuyPlanDetail:DetailBase
    {
       public BuyPlanDetail():base()
       public BuyPlanDetail(int detailID){....}
       public BuyPlanDetail(int DetailID,int ProductID):base(productID){.....}
    }之所以在BuyPlanDetail中要有两个建构函数:BuyPlanDetail(int detailID)和BuyPlanDetail(int detailID,int productID),因为detailID和productID是不一样的概念,所以不能直接在BuyPlanDetail(int detailID)后面添加:base(int productID),因为productID还没有取得。我采用了上述思路后发现不行,应该怎么解决,烦请各位高手帮忙测试一下。程序困死在这里了……郁闷极了
      

  4.   

    take my advice, redesign your class, use a common method, you might need to give productID a default value
      

  5.   

    productID没有赋予Defaule Value的,因为这个Default Value根本没有意义。
      

  6.   

    的确有点困难,按照你的思路我也想不出解决之道。
    我认为你的这种对象构造方式不容易实现。另外,建议使用类型的静态方法来实现,这样比较容易。
    public static BuyPlanDetail GetByDetailId(int dID) // 此方法添加到 BuyPlanDetail
    {
    DB db=new DB();
    string sql="select * from bz_BuyPlanDetail where bpDeatilID="+dID.ToString();
    SqlDataReader dr=db.GetSqlDataReader(sql);
    int pID = -1;
             if(dr.Read())
    {
                pID = DB.GetInt(dr["productID"]);
    }
    db.CloseConn();         return new BuyPlanDetail(dID, pID);
    }
    异常及其他判断逻辑你自己添加。