谁能举个委托当参数传递的例子 谁能举个委托当参数传递的例子,小弟不太理解!!简单点就好! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 .net 类库里面就有很多了public T Find(System.Predicate<T> match) Member of System.Collections.Generic.List<T> static void Main(string[] args) { 做菜 zc = new 做菜(delegate(object o) { Console.WriteLine("我要开始做" + o.ToString() + "啦"); }); 订餐(zc, true); #endregion } public delegate void 做菜(object 菜); public static void 订餐(做菜 zc,bool 有没有菜) { if (有没有菜) zc("东坡肉"); }/*输出:我要开始做东坡肉啦*/ using System.Threading; public delegate void MyInvoke(string str); private void btnStartThread_Click(object sender, EventArgs e) { Thread thread = new Thread(new ThreadStart(DoWord)); thread.Start(); } public void DoWord() { MyInvoke mi = new MyInvoke(SetTxt); BeginInvoke(mi,new object[]{"abc"}); } public void SetTxt(string str) { txtReceive.Text += str + System.Environment.NewLine; } c#如何实现以下效果? 分析网页的问题 C# 如何向数SQL据库中写入 money 类型的数据 大侠请进,将一个浮点数转换为IEEE浮点格式?急!!!100分相送。 如何让一个窗口变成对话框? 问题解决了,不用加班了!cancersyf(fengzhimei)过来领分. 怎么往SQL加整型数据? C#中的即时聊天程序问题? C#用五个类加减乘除及乘方类实现一个接口的功能,得不到理想的结果为什么? --sqlserver多个存储过程调用先后顺序的问题; C#窗体中数据库更新问题 引用的问题
public T Find(System.Predicate<T> match)
Member of System.Collections.Generic.List<T>
static void Main(string[] args)
{
做菜 zc = new 做菜(delegate(object o)
{
Console.WriteLine("我要开始做" + o.ToString() + "啦");
});
订餐(zc, true);
#endregion } public delegate void 做菜(object 菜); public static void 订餐(做菜 zc,bool 有没有菜)
{
if (有没有菜)
zc("东坡肉");
}
/*
输出:
我要开始做东坡肉啦*/
private void btnStartThread_Click(object sender, EventArgs e)
{
Thread thread = new Thread(new ThreadStart(DoWord));
thread.Start();
}
public void DoWord()
{
MyInvoke mi = new MyInvoke(SetTxt);
BeginInvoke(mi,new object[]{"abc"});
} public void SetTxt(string str)
{
txtReceive.Text += str + System.Environment.NewLine;
}