簡單委託例子

2021-05-22 12:30:18 字數 769 閱讀 9559

例子1:using system;

using system.collections.generic;

using system.text;

例子2:

using system;

using system.collections.generic;

using system.text;

namespace 介面

class program

console.writeline();

console.writeline("矩形面積為:", jx.jxmj(a, b));

console.writeline("正方形面積為:", zf.zfxmj(c));

console.writeline("圓面積為:", y.ymj(d));

console.writeline("梯面積為:", tx.txmj(e,f,g));

console.write("結束");

console.read();}}

class area

public int zfxmj(int bc)

public double  ymj(int r)

public float txmj(int sd, int xd, int g)}}

簡單的Delegate 委託 例子

今天學習一下好久都不願意碰的delegate,雖然不是很明白,還是寫了乙個小例子 參考園子裡的朋友們的 希望加深一下印象.朋友們說它類似於c 的函式指標,指向乙個函式,執行的時候可以呼叫這個函式.步驟 1.宣告乙個delegate物件。2.實現和delegate具有相同引數和返回值的函式實現 可以是...

c 委託delegate簡單例子

code using system using system.collections.generic using system.linq using system.text namespace delegate 可以供繼承自heater的類重寫,以便繼承類拒絕其他物件對它的監視 protected ...

委託的例子

namespace 委託例子 定義委託 public delegate void speakdelegate string name public static void chinesesepaking string name 我是中國人!name public static void englis...