c# lambda濡備綍绠€鍖栧鎵樿皟鐢?
鍦–#涓紝鍙互浣跨敤lambda琛ㄨ揪寮忔潵绠€鍖栧鎵樿皟鐢ㄣ€備笅闈㈡槸涓€涓畝鍗曠殑绀轰緥锛?/p>
鍋囪鏈変竴涓鎵樼被鍨嬩负Action<int, int>锛岀敤鏉ヨ〃绀烘帴鍙椾袱涓猧nt绫诲瀷鍙傛暟骞朵笖娌℃湁杩斿洖鍊肩殑鏂规硶銆?/p>
浼犵粺鐨勫鎵樿皟鐢ㄦ柟寮忓涓嬶細
Action<int, int> myAction = (x, y) => Console.WriteLine(x + y);
myAction(2, 3);
浣跨敤lambda琛ㄨ揪寮忓彲浠ョ畝鍖栦负锛?/p>
Action<int, int> myAction = (x, y) => Console.WriteLine(x + y);
myAction.Invoke(2, 3);
杩欐牱鍙互鏇村姞绠€娲佸湴璋冪敤濮旀墭鏂规硶銆俵ambda琛ㄨ揪寮忕殑璇硶浣垮緱浠g爜鏇村姞娓呮櫚鍜屾槗浜庣悊瑙c€?/p>
相关问答