首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

简单的有关问题

2012-03-22 
简单的问题麻烦讲讲委托,它是怎么实现的,为什么要用委托,就像在线程中我如果要调用控件就会用到委托来异步

简单的问题
麻烦讲讲委托,它是怎么实现的,为什么要用委托,就像在线程中我如果要调用控件就会用到委托来异步调用,最好使用自己的话组织,谢谢谢谢

[解决办法]
http://www.cnblogs.com/cntour365/archive/2008/08/29/1279757.html
这篇写的很详细
[解决办法]

C# code
class MainClass{    // Regular method that matches signature:    static void SampleDelegateMethod(string message)    {        Console.WriteLine(message);    }    static void Main()    {        // Instantiate delegate with named method:        SampleDelegate d1 = SampleDelegateMethod;        // Instantiate delegate with anonymous method:        SampleDelegate d2 = delegate(string message)        {             Console.WriteLine(message);         };        // Invoke delegate d1:        d1("Hello");        // Invoke delegate d2:        d2(" World");    }} 

热点排行