This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var personCount = personList.Count(); | |
Console.WriteLine(personCount); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var personMin = personList.Min(p => p.Age); | |
Console.WriteLine(personMin); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var personMax = personList.Max(p => p.Age); | |
Console.WriteLine(personMax); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var personTake = personList.Take(3); | |
foreach (Person p in personTake) | |
{ | |
Console.WriteLine(p.Name + " : " + p.Age); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var personOrderByDesc = personList.OrderByDescending(p => p.Age); | |
foreach (Person p in personOrderByDesc) | |
{ | |
Console.WriteLine(p.Name + " : " + p.Age); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var personOrderBy = personList.OrderBy(p => p.Age); | |
foreach (Person p in personOrderBy) | |
{ | |
Console.WriteLine(p.Name + " : " + p.Age); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var person2b = personList.Where(p => p.Name == "とぅーびー").ToList(); | |
foreach (Person p in person2b) | |
{ | |
Console.WriteLine(p.Name + " : " + p.Age); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var personName = personList.Select(p => p.Name); | |
Console.WriteLine(string.Join(", ",personName)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void Main(string[] args) | |
{ | |
List<Person> personList = new List<Person>(); | |
personList.Add(new Person() { Name = "ほげほげ太郎", Age = 20 }); | |
personList.Add(new Person() { Name = "ほげほげ太郎", Age = 21 }); | |
personList.Add(new Person() { Name = "はげはげ太郎", Age = 45 }); | |
personList.Add(new Person() { Name = "しーしゃーぷ", Age = 32 }); | |
personList.Add(new Person() { Name = "しーしぇぱーど", Age = 26 }); | |
personList.Add(new Person() { Name = "とぅーびー", Age = 15 }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Person | |
{ | |
public string Name { get;set; } | |
public int Age { get;set; } | |
} |