用C#写个关于类的程序

来源:百度知道 编辑:UC知道 时间:2024/05/19 10:48:57
创建一个类A,并写出该类的构造函数用以输出"class A",再创建一个类B,类B继承类A,同样在类B中写出其构造函数用以输出"class B",
再在类B中写一个方法show(),输出"show".再创建一个类C,在类C的主函数中调用类B中的方法show()
输出结果应为:
class A
class B
show

新手学C# 尽量让我能看懂就行了
谢谢

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

namespace ConsoleApplication25
{
class A
{
public A()
{ Console.WriteLine("class A"); }
}
class B : A
{
public B()
{
Console.WriteLine("class B");

}
public void show()
{ Console.WriteLine("show"); }
}

class C
{
static void Main(string[] args)
{

B b = new B();
b.show();

}
}
}
祝你成功!!

namespace ConsoleApplication
{
class C
{
static void Main(string[] args)
{
B bb = new B();
bb.show();
}
}

class A
{
public A()