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


C# Dog.PrintSound方法代码示例

本文整理汇总了C#中Dog.PrintSound方法的典型用法代码示例。如果您正苦于以下问题:C# Dog.PrintSound方法的具体用法?C# Dog.PrintSound怎么用?C# Dog.PrintSound使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dog的用法示例。


在下文中一共展示了Dog.PrintSound方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

    static void Main()
    {
        Dog dogOne = new Dog("Sharo", "male", 7);
        Dog dogTwo = new Dog("Sara", "female", 17);
        Dog dogThree = new Dog("Tara", "female", 1);
        Dog[] dogArr = new Dog[] { dogOne, dogTwo, dogThree };
        Console.WriteLine("The average age of dogs is {0:F2} years old.", Animal.CalculateAverage(dogArr));
        Console.WriteLine("Dog {0} says {1}.", dogThree.Name, dogThree.PrintSound());

        Frog frogOne = new Frog("Skokla", "female", 23);
        Frog frogTwo = new Frog("Handsome", "male", 9);
        Frog frogThree = new Frog("Skokancho", "male", 2);
        Frog[] frogArr = new Frog[] { frogOne, frogTwo, frogThree };
        Console.WriteLine("The average age of frogs is {0:F2} years old.", Animal.CalculateAverage(frogArr));
        Console.WriteLine("Frog {0} says {1}.", frogThree.Name, frogThree.PrintSound());

        Kitten kittenOne = new Kitten("Hihi", 1);
        Kitten kittenTwo = new Kitten("Kiki", 1);
        Kitten kittenThree = new Kitten("Kenny", 2);
        Kitten[] kittenArr = new Kitten[] { kittenOne, kittenTwo, kittenThree };
        Console.WriteLine("The average age of kittens is {0:F2} years old.", Animal.CalculateAverage(kittenArr));
        Console.WriteLine("Kitten {0} says {1}.", kittenThree.Name, kittenThree.PrintSound());

        Tomcat tomcatOne = new Tomcat("Pancho", 4);
        Tomcat tomcatTwo = new Tomcat("Robby", 3);
        Tomcat tomcatThree = new Tomcat("Vasko", 8);
        Tomcat[] tomcatArr = new Tomcat[] { tomcatOne, tomcatTwo, tomcatThree };
        Console.WriteLine("The average age of tomcats is {0:F2} years old.", Animal.CalculateAverage(tomcatArr));
        Console.WriteLine("Tomcat {0} says {1}.", tomcatThree.Name, tomcatThree.PrintSound());
    }
开发者ID:bankova,项目名称:CSharp,代码行数:30,代码来源:AnimalsArrays.cs


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