在一个按钮事件中有如下代码:
我打算把bean的对象作为参数传递给另一个方法.可当我把参数加到bean对象时报错.请问是什么原因?谢谢.
        string popeNum = this.txtPopeNum.Text.Trim();
        string name = this.txtName.Text.Trim();
        string work = this.txtWork.Text.Trim();
        string tell = this.txtTell.Text.Trim();
        string note = this.txtNote.Text.Trim();
        int checkDepName = ph.checkDepName("proc_searchDepName", name);
        int checkpope = ph.checkSqlPope("proc_searchSqlName", popeNum);        //下面这行代码有错误.提示:错误:   "DepartmentBean”方法没有采用“5”个参数的重载         DepartmentBean dt = new DepartmentBean(name, work, tell, popeNum,note);
        int result = ph.insertDep(dt);

解决方案 »

  1.   

    DepartmentBean(name, work, tell, popeNum,note); 
    这个函数的参数个书不是个或者该函数的参数类型不匹配。
      

  2.   

    类型,个数没什么问题啊.都是string的,一共5个参数.
    下面是bean的内容.
    using System;
    using System.Collections.Generic;
    using System.Text;namespace Model
    {
        public class DepartmentBean
        {
            private string departmentName;
            public string DepartmentName
            {
                get { return departmentName; }
                set { departmentName = value; }
            }        private string departmentWork;
            public string DepartmentWork
            {
                get { return departmentWork; }
                set { departmentWork = value; }
            }        private string departmentTell;
            public string DepartmentTell
            {
                get { return departmentTell; }
                set { departmentTell = value; }
            }        private string departmentNote;
            public string DepartmentNote
            {
                get { return departmentNote; }
                set { departmentNote = value; }
            }        private string popeNum;
            public string PopeNum
            {
                get { return popeNum; }
                set { popeNum = value; }
            }
        }
    }
      

  3.   

    DepartmentBean(name, work, tell, popeNum,note); 
    这个函数的参数个数有问题。仔细检查下
      

  4.   

    晕,你这个DepartmentBean 是一个实体类而已,不是一个方法,你把他当作方法来用就错了。
    DepartmentBean dt = new DepartmentBean(); 
    dt.DepartmentName =name;
    .......
    是这样用的
      

  5.   

    或者你给DepartmentBean写个 
    构造函数传5个参数.