多级继承的 C# 示例
当派生类由另一个派生类形成时就会发生多级继承。
在 C# 中,祖父、父亲和儿子是表示多级继承的完美示例 −

示例
以下是说明在 C# 中使用多级继承的示例。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Demo {
class Son : Father {
public void DisplayTwo() {
Console.WriteLine("Son.. ");
}
static void Main(string[] args) {
Son s = new Son();
s.Display();
s.DisplayOne();
s.DisplayTwo();
Console.Read();
}
}
class Grandfather {
public void Display() {
Console.WriteLine("Grandfather...");
}
}
class Father : Grandfather {
public void DisplayOne() {
Console.WriteLine("Father...");
}
}
}输出
Grandfather... Father... Son..
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP