专注于互联网--专注于架构

最新标签
网站地图
文章索引
Rss订阅

首页 »DotNet » system.linq:方便的System.Linq »正文

system.linq:方便的System.Linq

来源: 发布时间:星期五, 2008年9月26日 浏览:94次 评论:0
//List<T>.Select method
//Create the data source
List<int> Scores = new List<int>() { 97, 92, 81, 60 };
// Create the query.
IEnumerable<int> queryHighScores = from score in Scores where score > 80 select score;
// Execute the query.
foreach (int i in queryHighScores)
{
Console.WriteLine(i + " ");
}


// Simple data source. Arrays support IEnumerable<T>.
int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };

// Simple query with _disibledevent=
from num in numbers
where num < 5
select num;

// Execute the query.
foreach (var s in queryLowNums)
{
Console.WriteLine(s.ToString() + " ");
}
//エラ 6 ソス型 'int[]' のクエリ パタンの装がつかりませんでした。'Where' がつかりません。'System.Core.dll' への参照または 'System.Linq' のディレクティブの使用は指定されていますか?
//解决方法:
//1.在参照设定中追加System.Core
//2.使用命名空间:using System.Linq;
//to be continue......

相关文章

读者评论

  • 共0条 分0页

发表评论

  • 昵称:
  • 内容: