博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

.NET Framework 3.0 以上,支持LinQ

Posted on 2009-08-04 16:52  冷咖啡(子锡)  阅读(189)  评论(0编辑  收藏  举报

.NET Framework 3.0 以上,支持LinQ
1,2,3,4,5,2,1,9

统计各字符出现次数,语言不限,

程序代码 程序代码
using System.Collections;

int[] scores = new int[] { 97, 92, 81, 60 };
for (int i = 0; i < scores.Length; i++) {
  int localNum=scores.GetValue(i);

  IEnumerable<int> query =
    from score in scores
    where score = localNum
    select score;

  int scoreCount = query.Count();
  Response.Write(scoreCount.toString());
}