Tak*_*ami 0 c# asp.net inheritance visual-studio
我怎样才能继承这个类,当我尝试继承它时会给我一个错误.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class expresion2 : System.Web.UI.Page
{
public String nombre, email, telefono, contra, usuario;
protected void Page_Load(object sender, EventArgs e)
{
nombre = txtNombre.Text;
email = txtEmail.Text;
telefono = txtTel.Text;
contra = txtContra.Text;
usuario = txtUser.Text;
}
}
Run Code Online (Sandbox Code Playgroud)
当我尝试继承"expresion2"时,它在VS studio 2016上给出了编译错误
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class mostrar2 : expresion2
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
Run Code Online (Sandbox Code Playgroud)
小智 6
您的mostrar2和expression2类未在命名空间中定义.
正确的定义如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace myNamespace
{
public partial class expresion2 : System.Web.UI.Page
{
public String nombre, email, telefono, contra, usuario;
protected void Page_Load(object sender, EventArgs e)
{
nombre = txtNombre.Text;
email = txtEmail.Text;
telefono = txtTel.Text;
contra = txtContra.Text;
usuario = txtUser.Text;
}
}
}
Run Code Online (Sandbox Code Playgroud)
和;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace myNamespace
{
public partial class mostrar2 : expresion2
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
61 次 |
| 最近记录: |