⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.cs

📁 Visual C#2005程序设计教程
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WinApp7_1派生类
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {/* */
            Cuboid cuboid = new Cuboid();
            cuboid.Length = 8; cuboid.Width = 5; cuboid.High = 3;
            label1.Text = "长方体的长宽高为:" + cuboid.Length + "  "
                + cuboid.Width+"  "+cuboid.High
                +"\n长方体的体积为:"+cuboid.CuboidCubage( );
            Cube cube = new Cube();
            cube.Length = 15;
            label1.Text += "\n正方体的棱长为:" + cube.Length
                +"\n正方体的体积为:"+cube.CubeCubage();
        }
    }
    public class Cuboid
    {
        protected double length;
        private double width;
        private double high;
        public double Length { get { return length; } set { length = value; } }
        public double Width { get { return width; } set { width = value; } }
        public double High { get { return high; } set { high = value; } }
        //public Cuboid(double l, double w, double h)
        //{ length = l; width = w; high = h; }
        public double CuboidCubage()
        { return length * width * high; }
    }
   public class Cube : Cuboid
    {
       //public Cube(double l) : base(l, 0, 0) { }
       public double CubeCubage()
       { return length * length * length; }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -