Linq

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Collections;
using System.Threading.Tasks;
namespace test
{
  public class teste {
      
      static void Main()
      {
          string[] contries = new string[] { "china", "russia", "american", "spain", "japan", "china" };
         // var query = from a in contries select a;//Linq to object  
          var query = from c in contries.Distinct() 
                      where c.Length == 5 
                      orderby c //按大小进行排序
                      ascending select c; 
          IEnumerator enumerator = query.GetEnumerator();
          while (enumerator.MoveNext())
          {
              Console.WriteLine(enumerator.Current);
          }  
          Console.ReadKey();
      }
   }
  }
View Code

 

posted @ 2017-04-22 09:34  ADFL  阅读(112)  评论(0编辑  收藏  举报