Skip to content

Instantly share code, notes, and snippets.

View peyangu's full-sized avatar

peyangu peyangu

View GitHub Profile
@peyangu
peyangu / Program.cs
Created April 15, 2017 14:45
Countメソッド
var personCount = personList.Count();
Console.WriteLine(personCount);
@peyangu
peyangu / Program.cs
Created April 15, 2017 14:44
Minメソッド
var personMin = personList.Min(p => p.Age);
Console.WriteLine(personMin);
@peyangu
peyangu / Program.cs
Created April 15, 2017 14:44
Maxメソッド
var personMax = personList.Max(p => p.Age);
Console.WriteLine(personMax);
@peyangu
peyangu / Program.cs
Created April 11, 2017 12:52
Takeメソッド
var personTake = personList.Take(3);
foreach (Person p in personTake)
{
Console.WriteLine(p.Name + " : " + p.Age);
}
@peyangu
peyangu / Program.cs
Created April 11, 2017 12:37
OrderByDescendingメソッド
var personOrderByDesc = personList.OrderByDescending(p => p.Age);
foreach (Person p in personOrderByDesc)
{
Console.WriteLine(p.Name + " : " + p.Age);
}
@peyangu
peyangu / Program.cs
Created April 11, 2017 12:30
OrderByメソッド
var personOrderBy = personList.OrderBy(p => p.Age);
foreach (Person p in personOrderBy)
{
Console.WriteLine(p.Name + " : " + p.Age);
}
@peyangu
peyangu / Program.cs
Created April 11, 2017 12:29
Whereメソッド
var person2b = personList.Where(p => p.Name == "とぅーびー").ToList();
foreach (Person p in person2b)
{
Console.WriteLine(p.Name + " : " + p.Age);
}
@peyangu
peyangu / Program.cs
Created April 11, 2017 12:23
Selectメソッド
var personName = personList.Select(p => p.Name);
Console.WriteLine(string.Join(", ",personName));
@peyangu
peyangu / Program.cs
Created April 11, 2017 12:22
LINQ説明用Program.cs
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 });
@peyangu
peyangu / Person.cs
Created April 11, 2017 12:21
Personクラス
public class Person
{
public string Name { get;set; }
public int Age { get;set; }
}