日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
C#多路廣播簡單描述

C#語言有很多值得學(xué)習(xí)的地方,這里我們主要介紹C#多路廣播,包括介紹多路代理MSDN上翻譯成C#多路廣播等方面。

10余年的云縣網(wǎng)站建設(shè)經(jīng)驗,針對設(shè)計、前端、開發(fā)、售后、文案、推廣等六對一服務(wù),響應(yīng)快,48小時及時工作處理。全網(wǎng)整合營銷推廣的優(yōu)勢是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動調(diào)整云縣建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計,從而大程度地提升瀏覽體驗。創(chuàng)新互聯(lián)建站從事“云縣網(wǎng)站設(shè)計”,“云縣網(wǎng)站推廣”以來,每個客戶項目都認(rèn)真落實執(zhí)行。

一個代理同時代理幾個方法。就是我們前面說到的那樣,你去建造房子,現(xiàn)在要不僅僅是建造住宅,還的去建造花園等等其它建筑物??墒撬鼈兌际窃诮ㄔ旆孔?,傳遞的參數(shù)也相同返回值的類型也相同都是房屋。那么我們?yōu)槭裁床徽乙粋€代理人來完成這樣的任務(wù)呢?把這些事物交由他一個人來完成不是可以節(jié)省我們很多的時間和金錢。是的我們可以那樣做System。MulticastDelegate 實際上在.net framework中你還可以找到這個類,多路代理MSDN上翻譯成C#多路廣播。事實上它還重載了操作符+=。其實C#多路廣播和單路代理在使用方法上區(qū)別不大。你可以看下面的例子。

 
 
 
  1. using System;
  2. namespace Multi_castDelegate
  3. {
  4. /// 
  5. /// Summary description for Class1.
  6. /// 
  7. class MyClassDelegate
  8. {
  9. /// 
  10. /// The main entry point for the application.
  11. /// 
  12. public delegate string IntDelegate(string s);
  13. }
  14. }
  15. using System;
  16. namespace Multi_castDelegate
  17. {
  18. /// 
  19. /// Summary description for MyImplementingClass.
  20. /// 
  21. public class MyClass
  22. {
  23. public MyClass()
  24. {
  25. }
  26. public static string WriteString(string s)
  27. {
  28. Console.WriteLine("Writing string");
  29. return "null";
  30. }
  31. public static string logString(string s)
  32. {
  33. Console.WriteLine("loging string");
  34. return "null";
  35. }
  36. public static string TransmitString(string s)
  37. {
  38. Console.WriteLine("Transmitting string");
  39. return "null";
  40. }
  41. }
  42. }
  43. The Main class:
  44. using System;
  45. using System.Threading;
  46. namespace Multi_castDelegate
  47. {
  48. /// 
  49. /// Summary description for Test.
  50. /// 
  51. public class Test
  52. {
  53. public static void Main()
  54. {
  55. MyClassDelegate.StringDelegate
  56. Writer,Logger,Transmitter;
  57. MyClassDelegate.StringDelegate
  58. myDelegate;
  59. Writer=new
  60. MyClassDelegate.StringDelegate(MyClass.WriteString);
  61. /// calling Writer
  62. Writer("hello i am Writer just acting like Single cast");
  63. Logger=new MyClassDelegate.StringDelegate(MyClass.logString);
  64. ///calling Logger
  65. Logger("hello i am Logger just acting like Single-cast");
  66. Transmitter=new MyClassDelegate.StringDelegate(MyClass.TransmitString);
  67. ///calling Transmitter
  68. Transmitter("hello i am Transmitter just acting like Single-cast");
  69. ///here mydelegate used the Combine method of System.MulticastDelegate
  70. ///and the delegates combine
  71. myDelegate=(MyClassDelegate.StringDelegate)System.Delegate.
    Combine(Writer,Logger);
  72. myDelegate("used Combine");
  73. ///here Transmitter is also added using the overloaded form of Combine
  74. myDelegate+=Transmitter;
  75. myDelegate("Using Overloaded Form");
  76. ///now using the Remove method
  77. myDelegate=(MyClassDelegate.StringDelegate)System.Delegate.
    Remove(myDelegate,Writer);
  78. myDelegate("Without Writer");
  79. ///overloaded Remove
  80. myDelegate-=Transmitter;
  81. myDelegate("Without Transmitter");
  82. System.Threading.Thread.Sleep(2300); 
  83. }
  84. }
  85. }

面的例子重點是看那兩個已經(jīng)重載的操作符。"-="和"+="。通過上面的例子,你可以清楚的看到C#多路廣播是如何一次代理多個方法的。當(dāng)然你也可以刪除掉那些你不想要的用"-="操作符就可以了。


當(dāng)前名稱:C#多路廣播簡單描述
轉(zhuǎn)載來于:http://www.5511xx.com/article/dpdgspo.html