animal.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace work101
{
public class Animal
{
public string say;
public Animal()
{
this.say = "Animal 被构造 ";
}
}
//继承类,会先行构造自己的父类
public class People : Animal
{
public string country;
public People()
{
this.say += " People 被构造";
}
}
}
webform1.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace work101
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
work101.Animal a1 = new Animal();
Response.Write(a1.say);
Response.Write("<br>");
work101.People p1 = new People();
Response.Write(p1.say);
Response.Write("<br>");
}
}
}