ConnectionLostEventHandler del = delegate(string information) {
txtContent.Text +=
String.Format("System[{0}]:\r\n{1}\r\n", DateTime.Now, information);
};这是在表达什么? 看不明白,希望帮我解释下,懂了马上结贴!

解决方案 »

  1.   

    这表示将一个匿名函数赋值给一个委托变量del。你这个委托变量声明的时候肯定是带了一个string参数,同时返回值为void。
      

  2.   

    ConnectionLostEventHandler del = (s=>{
                    txtContent.Text +=
                        String.Format("System[{0}]:\r\n{1}\r\n", DateTime.Now, s);
                });
      

  3.   

    如果上边声明委托的时候返回值是string的时候
    是不是如下ConnectionLostEventHandler del =string delegate(string information) {
                    txtContent.Text +=
                        String.Format("System[{0}]:\r\n{1}\r\n", DateTime.Now, information);
                };
      

  4.   

    糊涂了,我明白了,有返回值的话,就在匿名方法里return
      

  5.   

    ConnectionLostEventHandler del =delegate(string information) {
                    txtContent.Text +=
                        String.Format("System[{0}]:\r\n{1}\r\n", DateTime.Now, information);
    return "";
                };