当前位置: 首页>>代码示例>>C#>>正文


C# Cat.MakeSound方法代码示例

本文整理汇总了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();

        }
开发者ID:ScreeM92,项目名称:Software-University,代码行数:47,代码来源:TestClass.cs


注:本文中的Cat.MakeSound方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。