简单的Linq查询

View Code
 1 //问题:1,查询出str中以@符号开头的
 2 //2,查询出Str中元素长度大于5的元素
 3 using System;
 4 using System.Linq;
 5 public class StudyLinq
 6 {
 7     public static void Main()
 8     {
 9         string[] str = {"abcd","apple","@symjie","banana","orange"};
10         var s = str.Where(p=>p.StartsWith("@"));
11         foreach (string a in s)
12         {
13             Console.WriteLine(a);
14         }
15         var c = str.Where(q=>q.Length>5);
16         foreach (string b in c)
17         {
18             Console.WriteLine(b);
19         }
20     }
21 }

 

posted @ 2012-08-01 19:59  晓 漪  阅读(438)  评论(0编辑  收藏  举报