webform1.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="dynamicweb3_15.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    </div>
    </form>
</body>
</html>

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 dynamicweb3_15
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        class Animal
        {
            int weight;
            int age;
            public Animal(int w, int a)
            {
                weight = w;
                age = a;
            }
            public string Dispaly(string name="Animal")
            {
                return name + " Weight=" + this.weight + ",age=" + this.age;
            }
        }
        //继承
        class Dog : Animal
        {
            public Dog(int w, int a)
                : base(w, a)
            {
                
            }

            public string Display(string name="Dog")
            {
                return base.Dispaly(name);
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            Dog wangcai = new Dog(10, 8);
            Label1.Text = wangcai.Dispaly("wangcai");
        }
    }
}