38 lines
804 B
C#
38 lines
804 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace BasicGramms
|
|
{
|
|
internal class BasicLinq
|
|
{
|
|
public void DoTest()
|
|
{
|
|
Character[] chs =
|
|
{
|
|
new Character() { Name = "Johnson", Age = 5, Address = "New York"},
|
|
new Character() { Name = "Anderson", Age = 15, Address = "San Fransisco"},
|
|
new Character() { Name = "Pearson", Age = 20, Address = "Alaska"},
|
|
};
|
|
|
|
var linq = from ch in chs
|
|
where ch.Age >= 10
|
|
select ch;
|
|
|
|
foreach (var item in linq)
|
|
{
|
|
Console.WriteLine($"Name: {item.Name}, Age: {item.Age}, Address: {item.Address}");
|
|
}
|
|
}
|
|
}
|
|
|
|
internal class Character
|
|
{
|
|
public string Name { get; set; }
|
|
public int Age { get; set; }
|
|
public string Address { get; set; }
|
|
}
|
|
}
|