static void Main() { // Attention! - No animals were harmed during these tests Console.Title = "Animals"; var dog = new Dog("Gosho", 3, Gender.Male); Console.WriteLine(dog); dog.FetchStick(); Console.Write(Environment.NewLine); var frog = new Frog("Masha", 16, Gender.Female); Console.WriteLine(frog); frog.Transform(); Console.Write(Environment.NewLine); var kitty = new Kitten("Maca", 0); Console.WriteLine(kitty); kitty.MeltYourHeart(); Console.Write(Environment.NewLine); var tomcat = new Tomcat("Tom", 4); Console.WriteLine(tomcat); tomcat.Piss(); Console.Write(Environment.NewLine); var animals = new Animal[] { new Dog("Freya", 1, Gender.Female), new Dog("Sharo", 4, Gender.Male), new Frog("Penka", 20, Gender.Female), new Frog("Fred", 32, Gender.Male), new Kitten("Merlin", 1), new Kitten("Shusia", 0), new Tomcat("Felix", 6), new Tomcat("Silvester", 5), }; var averageAge = from an in animals group an by new { GroupName = an.GetType().Name } into gender select new { gender.Key.GroupName, AvarageAge = gender.Average(an => an.Age) }; foreach (var animal in averageAge) { Console.WriteLine(String.Format("Group: {0}, AvarageAge: {1:0.00}.", animal.GroupName, animal.AvarageAge)); } // And what does the Fox say? Oh, no foxes here... }
static void Main() { // create some animals from each class and print them Dog dog = new Dog("Sharo", 3, Gender.Male); Console.WriteLine(dog); dog.FetchStick(); Console.WriteLine(); Frog frog = new Frog("Kermit", 33, Gender.Male); Console.WriteLine(frog); frog.Jump(); Console.WriteLine(); Kitten kitty = new Kitten("Kitty", 1); Console.WriteLine(kitty); kitty.Cry(); Console.WriteLine(); Tomcat tomcat = new Tomcat("Tom", 12); Console.WriteLine(tomcat); tomcat.Piss(); Console.WriteLine(); // create an array of Animals Animal[] animals = new Animal[] { new Dog("Rex",3, Gender.Male), new Frog("Kekerica", 1, Gender.Female), new Kitten("Pisi", 1), new Tomcat("Tom",2), new Dog("Erik", 4, Gender.Male), new Frog("Penka", 1, Gender.Female), new Kitten("Jasmin", 2), new Tomcat("Kolio",6), new Dog("Bender",2, Gender.Male), new Frog("Ginka", 6, Gender.Female), new Kitten("Tedy", 1), new Tomcat("Muncho",4), }; // calculate the aveage age of each animal and print them var averageAge = from an in animals group an by new { GroupName = an.GetType().Name } into gr select new { GroupName = gr.Key.GroupName, AvarageAge = gr.Average(an => an.Age) }; foreach (var animal in averageAge) { Console.WriteLine(String.Format("Group: {0}, AvarageAge: {1:0.00}.", animal.GroupName, animal.AvarageAge)); } }
static void Main() { // Attention! - No animals were harmed during these tests Console.Title = "Animals"; var dog = new Dog("Gosho", 3, Gender.Male); Console.WriteLine(dog); dog.FetchStick(); Console.Write(Environment.NewLine); var frog = new Frog("Masha", 16, Gender.Female); Console.WriteLine(frog); frog.Transform(); Console.Write(Environment.NewLine); var kitty = new Kitten("Maca", 0); Console.WriteLine(kitty); kitty.MeltYourHeart(); Console.Write(Environment.NewLine); var tomcat = new Tomcat("Tom", 4); Console.WriteLine(tomcat); tomcat.Piss(); Console.Write(Environment.NewLine); var animals = new Animal[] { new Dog("Freya", 1, Gender.Female), new Dog("Sharo", 4, Gender.Male), new Frog("Penka", 20, Gender.Female), new Frog("Fred", 32, Gender.Male), new Kitten("Merlin", 1), new Kitten("Shusia", 0), new Tomcat("Felix",6), new Tomcat("Silvester", 5), }; var averageAge = from an in animals group an by new { GroupName = an.GetType().Name } into gender select new { gender.Key.GroupName, AvarageAge = gender.Average(an => an.Age) }; foreach (var animal in averageAge) { Console.WriteLine(String.Format("Group: {0}, AvarageAge: {1:0.00}.", animal.GroupName, animal.AvarageAge)); } // And what does the Fox say? Oh, no foxes here... }
static void Main(string[] args) { Dog dog = new Dog("Pesho", 3, Gender.Male); Console.WriteLine(dog); dog.FetchStick(); Console.WriteLine(); Frog frog = new Frog("Peter", 33, Gender.Male); Console.WriteLine(frog); frog.Jump(); Console.WriteLine(); Kitten kitty = new Kitten("Ioio", 1); Console.WriteLine(kitty); kitty.Cry(); Console.WriteLine(); Tomcat tomcat = new Tomcat("Gogo", 12); Console.WriteLine(tomcat); tomcat.Piss(); Console.WriteLine(); // create an array of Animals Animal[] animals = new Animal[] { new Dog("Ares",3, Gender.Male), new Frog("Mitko", 1, Gender.Female), new Kitten("Mac", 1), new Tomcat("Cotka",2), new Dog("Saires", 4, Gender.Male), new Frog("Stilian", 1, Gender.Female), new Kitten("Ioio", 2), new Tomcat("Antony",6), new Dog("Roy",2, Gender.Male), new Frog("Angelina", 6, Gender.Female), new Kitten("Alex", 1), new Tomcat("Mecjo",4), }; // calculate the aveage age of each animal and print them var averageAge = from an in animals group an by new { GroupName = an.GetType().Name } into gr select new { GroupName = gr.Key.GroupName, AvarageAge = gr.Average(an => an.Age) }; foreach (var animal in averageAge) { Console.WriteLine(String.Format("Group: {0}, AvarageAge: {1:0.00}.", animal.GroupName, animal.AvarageAge)); } }
static void Main() { // create some animals from each class and print them Dog dog = new Dog("Sharo", 3, Gender.Male); Console.WriteLine(dog); dog.FetchStick(); Console.WriteLine(); Frog frog = new Frog("Kermit", 33, Gender.Male); Console.WriteLine(frog); frog.Jump(); Console.WriteLine(); Kitten kitty = new Kitten("Kitty", 1); Console.WriteLine(kitty); kitty.Cry(); Console.WriteLine(); Tomcat tomcat = new Tomcat("Tom", 12); Console.WriteLine(tomcat); tomcat.Piss(); Console.WriteLine(); // create an array of Animals Animal[] animals = new Animal[] { new Dog("Rex", 3, Gender.Male), new Frog("Kekerica", 1, Gender.Female), new Kitten("Pisi", 1), new Tomcat("Tom", 2), new Dog("Erik", 4, Gender.Male), new Frog("Penka", 1, Gender.Female), new Kitten("Jasmin", 2), new Tomcat("Kolio", 6), new Dog("Bender", 2, Gender.Male), new Frog("Ginka", 6, Gender.Female), new Kitten("Tedy", 1), new Tomcat("Muncho", 4), }; // calculate the aveage age of each animal and print them var averageAge = from an in animals group an by new { GroupName = an.GetType().Name } into gr select new { GroupName = gr.Key.GroupName, AvarageAge = gr.Average(an => an.Age) }; foreach (var animal in averageAge) { Console.WriteLine(String.Format("Group: {0}, AvarageAge: {1:0.00}.", animal.GroupName, animal.AvarageAge)); } }