linq简单排序
//创建实体类 public class Programer { public String Name { get; set; } public String Language { get; set; } public String ID { get; set; } } Programer[] ps = new Programer[] { new Programer(){ Name="张?三y", Language="C#",ID="1"}, new Programer(){ Name="李?四?", Language="C#",ID="3"}, new Programer(){ Name="王?五?", Language="Java",ID="2"} }; //ascending表示升序排列,descending表示降序排列 var queryPs = from p in ps orderby p.ID ascending where p.Language == "C#" select new { Name = p.Name, Language = p.Language, ID=p.ID }; //foreach 循环输出 foreach (var p in queryPs) { Console.WriteLine(String.Format("Name:{0}\t\tLanguage:{1}\t\tID=:{2}", p.Name, p.Language,p.ID)); } Console.ReadLine();