委託的寫法

2022-09-20 12:00:21 字數 1071 閱讀 5556

using system;

namespace weituo

#region 委託的方法

#region 寫法一,需要寫出專門委託的函式,需要自定義委託

/// /// //委託宣告 -- 定義乙個簽名: 支援多個輸入引數

///

///

///

///

///

delegate double mathaction(double in_1, double in_2, double in_3);

//執行委託的方法

static void func1()

//委託執行的函式,最多支援16個輸入引數

static double double(double in_1, double in_2, double in_3)

#endregion

#region 寫法二,需要寫出專門委託的函式,不需要自定義委託(使用系統委託)

//執行委託的方法

static void func2()

//委託執行的函式,最多支援16個輸入引數

static double double16(double in_1, double in_2, double in_3, double in_4, double in_5, double in_6, double in_7, double in_8, double in_9, double in_10, double in_11, double in_12, double in_13, double in_14, double in_15, double in_16)

#endregion

#region 寫法三,不需要寫出專門委託的函式,不需要自定義委託

static funcresult = (in_1, in_2, in_3) => in_1 * in_2 * in_3 * 2;

static funcresult4 = (in_1, in_2, in_3) =>

;static void func3()

#endregion

#endregion

}}

委託的多種寫法

一 委託呼叫方式 1.最原始版本 delegate string plusstringhandle string x,string y class program static string plusstring string x,string y 2.原始匿名函式版 去掉 plusstring 方...

委託的幾種寫法

參考自jeffrey zhao的文章 net1.x public delegate void mydel3 string message public class methods public void testmethod2 string msg public class deltest 需要使用...

標準的事件和委託宣告寫法 C

標準的事件和委託宣告寫法 定義委託 public delegate void picchangehandler object sender,picchangeeventargs args 宣告切換事件 public static event picchangehandler picchange 呼叫...