我写了这样的函数类public class CmpInfPackage
{
private string name;
private string cas;
private int recordsPerPage;
public CmpInfPackage( string n,string c,int r )
{
name = n; cas = c;  recordsPerPage = r;
}
public string Name
{
get{return name;}
}
public string CAS 
{
get{return cas;}
}
public int RecordsPerPage
{
get{return recordsPerPage;}
}

}然后在页面中调用它
Session["CmpInfPackage"] = 
new Utility.CmpInfPackage( txtName.Text,txtCas.Text,Convert.ToInt32(drpr.SelectedItem.Text)) ;这应该没有问题的,可是它就是给我错误,c:\inetpub\wwwroot\sanqiweb\testCom.aspx.cs(63): 重载“CmpInfPackage”方法未获取“3”参数
但是参数就是三个啊!而且我把调用改为
Session["CmpInfPackage"] = 
new Utility.CmpInfPackage( txtName.Text,txtCas.Text,10) ;
也是同样的错误,究竟是什么原因啊!谢谢了!

解决方案 »

  1.   

    这样试试:
    Session["CmpInfPackage"] = new Utility().CmpInfPackage( txtName.Text,txtCas.Text,10) ;
      

  2.   

    Session["CmpInfPackage"] = 
    new Utility.CmpInfPackage( txtName.Text,txtCas.Text,Convert.ToInt32(drpr.SelectedItem.Text)) ;
    是在什么事件里写的
      

  3.   

    你可能是传递的三个参数有的是空值,导致出错,你可用如下方式打印出所有参数看看.
    this.Response.Write(txtName.Text + "|" + txtCas.Text + "|" + drpr.SelectedItem.Text);
    this.Response.End();
      

  4.   

    我这样试试的,没有一点错误。
    private void Button1_Click(object sender, System.EventArgs e)
    {
    Session["CmpInfPackage"] = 
    new TestWebControls.CmpInfPackage( "123","345",12) ;
    } private void Button2_Click(object sender, System.EventArgs e)
    {
    TestWebControls.CmpInfPackage objCmp = (CmpInfPackage)Session["CmpInfPackage"] ;
    TextBox1.Text = objCmp.CAS+objCmp.Name+objCmp.RecordsPerPage.ToString ();
    }   
      

  5.   

    可能你实例这个CmpInfPackage类时,txtName,txtCas和drpr还没有画出。