软件编程
位置:首页>> 软件编程>> C#编程>> c# 匿名方法的小例子

c# 匿名方法的小例子

  发布时间:2023-06-05 01:22:45 

标签:c#,匿名方法


// Create a handler for a click event.
button1.Click += delegate(System.Object o, System.EventArgs e)
                   { System.Windows.Forms.MessageBox.Show("Click!"); };

 

// Create a delegate.
delegate void Del(int x);

// Instantiate the delegate using an anonymous method.
Del d = delegate(int k) { /* ... */ };

 

void StartThread()
{
    System.Threading.Thread t1 = new System.Threading.Thread
      (delegate()
            {
                System.Console.Write("Hello, ");
                System.Console.WriteLine("World!");
            });
    t1.Start();
}

0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com