本文整理汇总了C#中Cat.MakeSound方法的典型用法代码示例。如果您正苦于以下问题:C# Cat.MakeSound方法的具体用法?C# Cat.MakeSound怎么用?C# Cat.MakeSound使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cat
的用法示例。
在下文中一共展示了Cat.MakeSound方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
Dog firstDog = new Dog(2, "Sharo");
Dog secondDog = new Dog(6, "Djaro");
Dog thirdDog = new Dog(1, "Tobi");
Dog fourthDog = new Dog(5, "Roni");
Dog[] dogs = new Dog[]
{
firstDog, secondDog, thirdDog, fourthDog
};
Console.WriteLine("The average age of the dogs is: {0}", Animal.GetAverageAge(dogs));
firstDog.MakeSound();
Console.WriteLine();
Cat firstCat = new Kitten(1, "Kitty");
Cat secondCat = new Tomcat(2, "Bojko");
Cat thirdCat = new Cat(4, "Myrzel", "male");
Cat[] cats = new Cat[]
{
firstCat,
secondCat,
thirdCat
};
Console.WriteLine("The average age of the cats is: {0}", Animal.GetAverageAge(cats));
Console.WriteLine();
Console.WriteLine("The kitten's name is: {0} ", firstCat.GetName());
Console.WriteLine("The kitten's age is: {0}", firstCat.GetAge());
Console.WriteLine("All kittens are {0}", firstCat.Sex);
firstCat.MakeSound();
Console.WriteLine();
Console.WriteLine("The tomcat's name is: {0}", secondCat.GetName());
Console.WriteLine("All tomcats are {0}", secondCat.Sex);
secondCat.MakeSound();
thirdCat.MakeSound();
Console.WriteLine();
Frog froggy = new Frog(22, "Prince");
froggy.MakeSound();
}