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

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

新聞中心

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

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

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

一個(gè)代理同時(shí)代理幾個(gè)方法。就是我們前面說(shuō)到的那樣,你去建造房子,現(xiàn)在要不僅僅是建造住宅,還的去建造花園等等其它建筑物。可是它們都是在建造房子,傳遞的參數(shù)也相同返回值的類(lèi)型也相同都是房屋。那么我們?yōu)槭裁床徽乙粋€(gè)代理人來(lái)完成這樣的任務(wù)呢?把這些事物交由他一個(gè)人來(lái)完成不是可以節(jié)省我們很多的時(shí)間和金錢(qián)。是的我們可以那樣做System。MulticastDelegate 實(shí)際上在.net framework中你還可以找到這個(gè)類(lèi),多路代理MSDN上翻譯成C#多路廣播。事實(shí)上它還重載了操作符+=。其實(shí)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. }

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


當(dāng)前標(biāo)題:C#多路廣播簡(jiǎn)單描述
瀏覽路徑:http://m.5511xx.com/article/dpdgspo.html