using#region using using System; using System.Data; using System.Configuration; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Text; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Collections.Generic; using System.Collections; #endregion
public partial class _Default : System.Web.UI.Page { protectedvoid Page_Load(object sender, EventArgs e) { 用First()选择查询结果的第一个元素#region 用First()选择查询结果的第一个元素 Response.Write("<hr>用First()选择查询结果的第一个元素<br>"); Student student = (from s in GetStudents() where s.Language =="Chinese" select s) .First(); Response.Write(string.Format("<div class='result'>{0},{1},{2}</div>", student.Name, student.Age, student.Language)); #endregion