You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
804 B
37 lines
804 B
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; }
|
|
}
|
|
}
|
|
|