[C#] C#中事件与委托的区别代码分析 →→→→→进入此内容的聊天室

来自 , 2021-03-20, 写在 C#, 查看 143 次.
URL http://www.code666.cn/view/dcd2f3f3
  1.  
  2. public delegate int Math(int a, int b);  
  3. public class Test  
  4. {  
  5.     public int Add(int a, int b)  
  6.     {  
  7.         return a + b;  
  8.     }  
  9. }  
  10. [TestClass]  
  11. public class UnitTest1  
  12. {  
  13.     [TestMethod]  
  14.     public void TestMethod1()  
  15.     {  
  16.         Math math = new Math(new Test().Add);  
  17.         math(1, 2);  
  18.     }  
  19. }  
  20.  
  21.  
  22. //csharp/5976

回复 "C#中事件与委托的区别代码分析"

这儿你可以回复上面这条便签

captcha