c# 匿名委托
无参:
if (this.tBReciveInfo.InvokeRequired) { this.Invoke(new Action(()=>{ this.tBReciveInfo.Text = message.Body.ToString(); })); }
一个参数:
1 private void act() 2 { 3 this.invoke(new Action<string>(s=>{方法(s);}),"参数s") 4 }
万能委托在原有基础上,更进一步,如下:
1 private void act()
2 {
3 this.invoke(new Action<string>(s=>{方法1(参数1);方法2(参数2);……方法n;}),"")
4 }
这里设置s的值为空值,把需要传的参数,直接写在方法里,做到多个参数传值的效果,而不用考虑s的值。

浙公网安备 33010602011771号