日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

【读书笔记】Lambda表达式

發布時間:2023/11/27 生活经验 54 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【读书笔记】Lambda表达式 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

??? Lambda表達式,是一個匿名函數,它可以包含表達式和語句,并且可用于創建委托或表達式目錄樹類型。

??? Lambda表達式, 都是用"=>"運算符。 讀作"goes to"。Lambda表達式運算符的左邊是輸入參數(如果有),右邊包含表達式或語句塊。使用格式如下:

(input parameters) => expression;
“Lambda表達式”是委托的實現方法,所以必須遵循以下規則:
  • 1)“Lambda表達式”的參數數量必須和“委托”的參數數量相同;
  • 2)如果“委托”的參數中包括有ref或out修飾符,則“Lambda表達式”的參數列中也必須包括有修飾符
大家都知道,一個類的私有成員只能在他的內部訪問!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace Lambda
{delegate bool D();delegate bool D2(int i);class Test{public D del;public D2 del2;public void TestMethod(int input){int j = 0;del = () => {j = 10;return j > input;};del2 = (x) =>{return x == j;};Console.WriteLine("j = {0}", j);bool boolResult = del();Console.WriteLine("j = {0}, b = {1}", j, boolResult); }}class Program{static void Main(string[] args){Test test = new Test();test.TestMethod(5);        bool result = test.del2(10);Console.WriteLine(result);Console.ReadKey();}}
}私有成員,在類外面不能引用.
private int x;
Cla cla = new Cla()
cla.x 這樣引用是錯的
?
如果public int x;
Cla cla = new Cla()
cla.x 這樣引用是對的
 

You can also create an anonymous method using an operator called lambda and represented by =>. From our example above, to use the lambda operator to create an anonymous method, omit the delegate keyword and follow the parentheses by the operator. Here is an example:

轉載于:https://www.cnblogs.com/herbert/archive/2010/03/22/1691766.html

總結

以上是生活随笔為你收集整理的【读书笔记】Lambda表达式的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。