继承aspx页面中的抽象类

时间:2015-07-23 03:55:44

标签: c# asp.net oop abstract

我知道c#中不支持多重继承。但我想通过保持System.Web.UI.Page原样从抽象类继承方法。例如..

abstract class stuff1()
{
 public abstract void print();
}

在aspx页面

 public partial class WebForm1: System.Web.UI.Page
 {
   //I want to implement print() method from abstract class here
  }

我们可以在aspx.cs文件后面的代码中继承抽象类的方法,如果是,那么如何?

1 个答案:

答案 0 :(得分:0)

您可以尝试从System.Web.UI.Page类扩展您的类。通过这种方式,您的网页可以从您的类继承,并可以扩展功能。

public abstract class stuff1 : Page
{
    public abstract void print();
}


public partial class _Default : stuff1
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    public override void print()
    {
        throw new NotImplementedException();
    }
}
相关问题