C#Linq选择方法
使用Select方法修改数组中的元素。
以下是我们的字符串数组。
string[] stationery = { "diary", "board", "pencil", "whiteboard" };Select方法还指定Lambda表达式,如下所示-
示例
using System;
using System.Linq;
using System.Collections.Generic;
public class Demo {
public static void Main() {
string[] stationery = { "diary", "board", "pencil", "whiteboard" };
var res = stationery.AsQueryable().Select((item, index) => new { result = item.Substring(0, index + 4) });
foreach (var str in res) {
Console.WriteLine("{0}", str);
}
}
}输出结果
{ result = diar }
{ result = board }
{ result = pencil }
{ result = whitebo }热门推荐
2 贫困户祝福语简短
10 元旦联谊祝福语简短精辟
11 六一祝福语简短感动女生
12 药店祝福语简短10字
13 公司开年仪式祝福语简短
14 生病祝福语简短文案
15 舅妈生日红包祝福语简短
16 青春告白祖国简短祝福语
17 红颜生日祝福语简短独特
18 高考送考祝福语简短