1 / 5
文档名称:

101个LINQ例子.docx

格式:docx   大小:66KB   页数:5页
下载后只包含 1 个 DOCX 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

101个LINQ例子.docx

上传人:changjinlai 2021/7/30 文件大小:66 KB

下载得到文件列表

101个LINQ例子.docx

相关文档

文档介绍

文档介绍:101个LINQ例子
Restriction Operators Where - Simple 1 public void Linql () { int [] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 } ; var lowNums = from n in numbers where n < 5 select n;
Console. WriteLine(\ foreach (var x in lowNums) Console. WriteLine(x); } }
Where - Simple 2 public void Linq2() {
List products = GetProductList(); var soldOutProducts = from p in products where p. UnitsInStock == 0 select p;
Console. WriteLine(\
foreach (var product in soldOutProducts) {
Console. WriteLine (\ } }
Where - Simple 3 public void Linq3() {
List products = GetProductList 0; var expensivelnStockProducts = from p in products
where p. UnitsInStock > 0 && p. UnitPrice > 3. OOM select p;
Console. WriteLine (\ foreach (var product in expensivelnStockProducts) { Console. WriteLine(\ }
)
Where - Drilldown public void Linq4() {
var waCustomers =
List customers = GetCustomerList();
from c in customers where c. Region == \
select c;
Console. WriteLine(\ foreach (var customer in waCustomers) { Console. WriteLine(\customer. CompanyName);
foreach (var order in customer. Orders) {
Console. WriteLine(\. OrderDate); } } }
Where - Indexed public void Linq5() {
string"! digits = { \ var shortDigits = digits. Where((digit, index)=> digit. Length < index); Console. WriteLine(\
foreach (var d in shortDigits) {
Console. WriteLine (\ ) }
Projection Operators
Select - Simple 1 public voi