C#教程之虚方法--重载

金沙澳门官网网址:www.js333com

VB.net 2010 视频教程 VB.net 2010 视频教程 VB.net 2010 视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > 编程开发 > C#编程 >
  • C#教程之虚方法--重载

  • 2019-10-19 10:28 来源:www.js333com
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
   public class Vehicle
    {
        public float weight;
        public Vehicle(float w)
        {
            weight = w;
        }
        public virtual void show()
        {
            Console.WriteLine("The weight of Vehicle is:" + weight);
        }
    }
    public class Car:Vehicle
    {
        int passengers;
    public Car(float w,int p):base(w)
        {
            passengers = p;
        }
        public override void show()
        {
            base.show();
            Console.WriteLine("The passengers of Car is:" + passengers);
        }
    }
    class Test
    {
        static void Main(string[] args)
        {
            Car c = new Car(6, 100);
            c.show();
            Console.Read();
        }
    }
}
相关教程
Baidu
sogou