Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
linq by Jean
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { class Program { public static void Main(string[] args) { var persons = new List<Person>(); Random rnd = new Random(); #region Arr persons.AddRange(new Person[]{ new Person { Name = "Fausto", LastName = "Garces", Age = 32, City = "Santo Domingo", Country = "The World" }, new Person { Name = "Jean", LastName = "Peña", Age = 26, City = "Santo Domingo", Country = "Dominican Republic" }, new Person { Name = "Ramon", LastName = "Rodriguez", Age = 2364, City = "Santo Domingo", Country = "Dominican Republic" }, new Person { Name = "Manuel", LastName = "Gonzalez", Age = 28, City = "Azua", Country = "Dominican Republic" }, new Person { Name = "Fernando", LastName = "Espinosa", Age = 32, City = "Bani", Country = "Dominican Republic" }, new Person { Name = "Eugenio", LastName = "Duran", Age = 12, City = "Miami FL", Country = "United State" }, }); #endregion var youndPeople = persons.Where(p => p.Age > 18).ToList(); var students = persons.Select(p => new Student { person = p, course = rnd.Next(100) }).ToList(); persons.ForEach((p) => { Console.WriteLine("Nombre: {0}; Edad:{1}; Pais:{2}", p.Name, p.Age, p.Country); }); Console.WriteLine(""); Console.WriteLine(""); students.ForEach((p) => { Console.WriteLine("Nombre: {0}; Edad:{1}; Pais:{2}; Curso:{3}", p.person.Name, p.person.Age, p.person.Country, p.course); }); Console.WriteLine(""); Console.WriteLine(""); persons.GroupBy(p => p.Country) .Select(gp => new { Country = gp.Select(g => g.Country).FirstOrDefault(), Count = gp.Count() }).ToList().ForEach( (gg) => { Console.WriteLine("Country: {0}; Count:{1}", gg.Country, gg.Count); }); //Console.ReadKey(); } } class Person { public String Name { get; set; } public String LastName { get; set; } public int Age { get; set; } public String City { get; set; } public String Country { get; set; } } class Student { public Person person { get; set; } public int course { get; set; } } }
run
|
edit
|
history
|
help
0
Multidimensional Arrays
mine
Square Real Matrix
Herencias
30272 Program Ex4 if
convert a string of numbers to a list then use a forEach to loop through the list
Binary search iterative approach
ShortBubbleSort
Why Linqdb is cool if you are a Csharper
pasar de binario a decimal