public class Example
{
public static void Main()
{
ShowLINQ_Collections();
}
private static void ShowLINQ_Collections()
{
List<Codekiller> codekillers = GetValues();
// LINQ를 이용한 Collection
var retValues = from theCodekiller in codekillers
where theCodekiller.Age < 22
orderby theCodekiller.Name
select theCodekiller;
foreach (Codekiller value in retValues)
{
Console.WriteLine(value.Name + " " + value.Age);
}
}
private static List<Codekiller> GetValues()
{
return new List<Codekiller>
{
{ new Codekiller() { Symbol="A", Name="codekiller1", Age=19}},
{ new Codekiller() { Symbol="B", Name="codekiller2", Age=20}},
{ new Codekiller() { Symbol="C", Name="codekiller3", Age=21}},
{ new Codekiller() { Symbol="D", Name="codekiller14", Age=22}}
};
}
}
public class Codekiller
{
public string Symbol { get; set; }
public string Name { get; set; }
public int Age { get; set; }
}