本文整理汇总了C#中Human.Talk方法的典型用法代码示例。如果您正苦于以下问题:C# Human.Talk方法的具体用法?C# Human.Talk怎么用?C# Human.Talk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Human
的用法示例。
在下文中一共展示了Human.Talk方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
// Because a Dog IS A Animal
// This is ok
Animal a = new Dog();
a.Talk();
// Same here... a has changed from a Dog instance to a Cat instance
// This is called Polymorphism
a = new Cat();
a.Talk();
Dog rover = new Dog();
rover.Talk();
Human bryan = new Human();
bryan.Talk();
Dog dori = new Dog();
dori.age = 3;
dori.name = "Dori";
dori.breed = "Mongrel";
Dog misty = new Dog();
misty.age = 3;
misty.breed = "King Charles";
misty.name = "Misty";
dori.Talk();
misty.Talk();
dori.age = 5;
misty.age = 3;
misty = dori;
misty.age = 4;
Console.WriteLine(dori.age);
Dog mrT = new Dog(7, "Mr T", "King Charles");
mrT.Talk();
Cat theo = new Cat();
theo.name = "Theodore";
theo.Talk();
while (theo.isAlive)
{
theo.Die();
}
Console.ReadLine();
}