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

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

C#入門經(jīng)典Lambda

2019-11-14 13:31:53
字體:
供稿:網(wǎng)友
 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5  6 namespace LambdaSample 7 { 8     class PRogram 9     {10         static void Main(string[] args)11         {12             int[] myIntArray = { 1,2, 3, 4, 5 };13             //累加器計(jì)算數(shù)組總和 14             int result = myIntArray.Aggregate((paramA, paramB) => paramA + paramB);15             int result1 = myIntArray.Aggregate<int>((paramA, paramB) => paramA + paramB);16             int result2 = myIntArray.Aggregate<int, int>(0, (paramA, paramB) => paramA + paramB);17             //遞歸計(jì)算數(shù)組總和18             int result3 = count(5);19             Console.WriteLine("The Result is: " + result);20             Console.WriteLine("The Result1 is: " + result1);21             Console.WriteLine("The Result2 is: " + result2);22             Console.WriteLine("The Result3 is: " + result3);23 24             string[] myStrArray = { "Admin", "Change", "ByPage" };25             //字符串?dāng)?shù)組拼接 何問起26             string strResult = myStrArray.Aggregate((paramA, paramB) => paramA + " " + paramB);27             //字符串?dāng)?shù)組字符串總長(zhǎng)度計(jì)算28             int result4 = myStrArray.Aggregate<string, int>(0, (a, b) => a + b.Length);29             //字符串?dāng)?shù)組拼接2,增加字符串"Some curries: "30             string strResult1 = myStrArray.Aggregate<string, string>("Some curries: ", (a, b) => a + " " + b);31             //字符串?dāng)?shù)組字符串總長(zhǎng)度計(jì)算2  hovertree.com32             int result5 = myStrArray.Aggregate<string, string, int>("Some curries: ", (a, b) => a + " " + b, a => a.Length);33             Console.WriteLine("The StrResult is: " + strResult);34             Console.WriteLine("The Result4 is: " + result4);35             Console.WriteLine(strResult1);36             Console.WriteLine("The Result5 is: " + result5);37             Console.ReadKey();38         }39 40         static int count(int n)41         {42             if (n == 1)43             {44                 return 1;45             }46             return n + count(n - 1);47         }48     }49 }

轉(zhuǎn)自:http://hovertree.com/h/bjaf/jf9yeju1.htm

參考:C# Lambda 實(shí)例代碼 深入淺出Lambda表達(dá)式 C#泛型詳細(xì)介紹

開發(fā)技術(shù)文章收集: http://www.survivalescaperooms.com/sosoft/p/kaifajishu.html


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 镇远县| 临邑县| 克什克腾旗| 卢龙县| 独山县| 青铜峡市| 华容县| 金华市| 德昌县| 广平县| 鞍山市| 图片| 东辽县| 锦州市| 河北省| 福清市| 栾川县| 锡林浩特市| 奉新县| 大关县| 兴宁市| 晋州市| 礼泉县| 阿拉善盟| 巴彦淖尔市| 扬中市| 托里县| 翼城县| 锦屏县| 金昌市| 木兰县| 马山县| 兴山县| 桃源县| 漳平市| 醴陵市| 化德县| 祁连县| 扎囊县| 高平市| 锡林郭勒盟|