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(); } } }
时间就像海绵里的水,只要你愿意挤,总还是有的——鲁迅