asp.net 4.5 练习~test13-2 linq
发布日期:2021-05-06 21:16:20 浏览次数:37 分类:精选文章

本文共 1517 字,大约阅读时间需要 5 分钟。

webform1.aspx

using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;namespace test13_2{    public partial class WebForm1 : System.Web.UI.Page    {        protected void Page_Load(object sender, EventArgs e)        {            List
dataM = new List
{ new News { title="冬奥会开幕了!",id=4888,categories="国际新闻"}, new News { title="中国第一艘航母下水!",id=4580,categories="中国新闻"}, new News { title="IPHONE 5S上市了!",id=4688,categories="国际新闻"}, new News { title="发行新股将实行注册制度!",id=3888,categories="中国新闻"}, new News { title="美国政府暂时停止工作!",id=2888,categories="国际新闻"}, new News { title="新兴市场股票大涨!",id=4568,categories="国际新闻"} }; var query1 = from str in dataM where str.categories == "国际新闻" orderby str.id descending select str.title; // select str; Response.Write("
热点新闻包括:
"); foreach (var news in query1) { Response.Write(news + "
"); //Response.Write(news.title + "
"); } } }}

news.cs  类

using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace test13_2{    class News    {        public int id { get; set; }        public string title { get; set; }        public string categories { get; set; }    }}

 

上一篇:asp.net 4.5 练习~test14-1 对磁盘操作
下一篇:asp.net 4.5 练习~test13-1 linq

发表评论

最新留言

路过按个爪印,很不错,赞一个!
[***.219.124.196]2025年04月01日 01时59分01秒