using System;
using System.Collections.Generic;
using System.Linq;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
var students = new[] {
new { LName="Jones", FName="Mary",Age=19, Major="History" },
new { LName="Smith", FName="Bob",Age=20, Major="CompSci" },
new { LName="Fleming", FName="Carol",Age=21, Major="History" }
};
var query = from student in students
orderby student.Age
select student;
foreach(var s in query)
{
Console.WriteLine("{0}, {1}: {2} - {3}",s.LName,s.FName,s.Age,s.Major);
}
}
}
}
C#orderby子句
最新推荐文章于 2024-05-28 08:48:31 发布