标签:blog http ar color 使用 sp on div 2014
今天在云和学院学了多态和接口,今天总结的可能不是很准确。

namespace Abstract
{
class chinese:person
{
public override void sayhi()
{
Console.WriteLine();
}
}
}
abstract class person
{
public string name { set; get; }
public void sayhello()
{
}
abstract public void sayhi();
}
virtual实例:
enum Gender
{
雌 = 1,
雄 = 2
}
class Bird
{
public virtual string Berk()
{
return "鸟鸣";
}
public string BName { set; get; }
public Gender BGender { set; get; }
public string Color { set; get; }
public string Category { set; get; }
public string Fly()
{
return "我会飞";
}
public string Eat()
{
return "吃饭";
}
public string Sleep()
{
return "睡觉";
}
public string Walk()
{
return "走路";
}
}
class Polly:Bird
{
public string WeiBa { set; get; }
public string SayHi(string word)
{
return word;
}
public override string Berk()
{
return "我会学人说话";
}
}
class dayan:Bird
{
public override string Berk()
{
return "大雁南飞";
}
}
static void Main(string[] args)
{
Bird b = new Polly();
Console.WriteLine(b.Berk());
dayan yan = new dayan();
Console.WriteLine(yan.Berk());
Console.ReadKey();
}
接口:完全抽象的一种约定,接口就是用来实现的。
[访问修饰符] interface 接口名
{
// 接口成员定义
}
Interface IfFly
{
void IFly();
}
interface Ifly
{
void Fly();
}
class Maque:Bird,Ifly
{
void Ifly.Fly()
{
Console.WriteLine("麻雀飞了");
}
}
class Program
{
static void Main(string[] args)
{
Ifly fly = new Maque();
fly.Fly();
Console.ReadKey();
}
}
标签:blog http ar color 使用 sp on div 2014
原文地址:http://www.cnblogs.com/songfang/p/4111398.html