0
点赞
收藏
分享

微信扫一扫

C#继承实例

洛茄 2022-09-05 阅读 38


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace ConsoleApplication1
{
class MyCar: Car
{
int people;

public MyCar(int w, float g, int p)
: base(w, g)
{
wheels = w;
weight = g;
people = p;

}

public void info()
{
Console.WriteLine("我有{0}个车轮", wheels);
Console.WriteLine("我重{0}kg", weight);
Console.WriteLine("我可以乘坐{0}个人", people);
}

public void speak()
{
Console.WriteLine("我能够加速");
}
public static void Main(String[] args)
{
MyCar myCar = new MyCar(4, 2000, 20);
myCar.info();
myCar.speak();
Console.ReadLine();
}
}
}


举报

相关推荐

c#的继承

C#封装,继承,多态

C#学习笔记_继承

C#实例应用

c# 类的继承例子

C#学习笔记之继承

C#中的类继承

0 条评论