手机
当前位置:查字典教程网 >编程开发 >C#教程 >c# 匿名方法的小例子
c# 匿名方法的小例子
摘要:复制代码代码如下://Createahandlerforaclickevent.button1.Click+=delegate(System...

复制代码 代码如下:

// 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();

}

【c# 匿名方法的小例子】相关文章:

c# 调用.bat文件的实现代码

C#简单的加密类实例

C#之IP地址和整数互转的小例子

c# datetime方法应用介绍

C#启动windows服务方法的相关问题分析

c# 类和成员的修饰详细介绍

C# 禁止应用程序多次启动的实例

c# 备忘录模式

c# 命名空间和程序集

c# 控件截图的简单实例

精品推荐
分类导航