复习接口
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 复习接口
{
class Program
{
static void Main(string[] args)
{
//父类引用指向子类对象。
Flyable f = new UFO();
f.Fly();
Console.ReadKey();
}
}
interface Flyable
{
void Fly();
}
class Bird : Flyable
{
public void Fly()
{
Console.WriteLine("小鸟飞呀飞");
}
}
class Plane : Flyable
{
public void Fly()
{
Console.WriteLine("灰机飞!");
}
}
class UFO : Flyable
{
public void Fly()
{
Console.WriteLine("看,飞碟!");
}
}
}
浙公网安备 33010602011771号