国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

關于linq的幾個小例子

2019-11-14 13:32:18
字體:
來源:轉載
供稿:網友
 PRivate void button1_Click(object sender, EventArgs e)        {            int[] numbers = new int[7] { 0,1,2,3,4,5,6};            var result0 = from num in numbers                          where (num % 2 == 0)                          select num;            foreach (int n in result0)            {                listBox1.Items.Add(n);            }        }        private void button2_Click(object sender, EventArgs e)        {            listBox1.Items.Clear();            int[] numbers = new int[7] { 2,3,2,4,3,5,5};            var result1 = from num in numbers                          where num > 3                          orderby num descending                          select num;            foreach (int n in result1)            {                listBox1.Items.Add(n);            }        }        private void button3_Click(object sender, EventArgs e)        {            listBox1.Items.Clear();            int[] numbers = new int[7] { 2, 3, 2, 4, 3, 5, 5 };            var result2 = from num in numbers                          where num > 3                          orderby num ascending                          select string.Format("當前值為{0}",num) ;            foreach (string  n in result2)            {                listBox1.Items.Add(n);            }        }        private void button4_Click(object sender, EventArgs e)        {            listBox1.Items.Clear();            int[] numbers = new int[7] { 2, 3, 2, 4, 3, 5, 5 };            int  result3 = (from num in numbers                           where num > 3                           select num).Count();            button4.Text += "--" + result3.ToString();        }

 


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 军事| 特克斯县| 黄梅县| 罗田县| 台北市| 新干县| 乐山市| 丹巴县| 合山市| 尼木县| 泾川县| 阳城县| 红桥区| 屏山县| 罗田县| 盐池县| 玉树县| 确山县| 宜城市| 鄄城县| 德令哈市| 腾冲县| 嘉荫县| 荔浦县| 固阳县| 金阳县| 沂南县| 澄城县| 浑源县| 休宁县| 河南省| 高要市| 祁连县| 高清| 红桥区| 高陵县| 图木舒克市| 黄平县| 禹州市| 洪洞县| 昭觉县|