手机
当前位置:查字典教程网 >编程开发 >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# 手动/自动保存图片的实例代码

winfrom 在业务层实现事务控制的小例子

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

C#中常使用进度条的代码

C#简单的加密类实例

C# 委托(delegate) 的小例子

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

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

C# 写入XML文档三种方法详细介绍

C# 获取属性名的方法

精品推荐
分类导航