C#中base的作用

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

namespace _05base关键字
{

//显示的调用父类的构造函数
//调用父类中的重名方法
class Program
{
static void Main(string[] args)
{
Student s = new Student();
Console.ReadKey();
}
}
public class Person
{
public void Test()
{
Console.WriteLine("我是父类");
}
}
public class Student:Person
{
public /*new*/ void Test()//new在子类中隐藏父类继承过来的方法
{
base.Test();
Console.WriteLine("我是子类");
}
}
}

posted @ 2018-05-11 11:44  枫影竹韵  阅读(1714)  评论(0编辑  收藏  举报