相关疑难解决方法(0)

42
推荐指数
4
解决办法
2万
查看次数

匿名方法与lambda表达式

任何人都可以提供匿名方法和lambda表达式之间的简洁区别吗?

使用匿名方法:

private void DoSomeWork()
{
    if (textBox1.InvokeRequired)
    {
        //textBox1.Invoke((Action)(() => textBox1.Text = "test"));
        textBox1.Invoke((Action)delegate { textBox1.Text = "test"; });
    }
}
Run Code Online (Sandbox Code Playgroud)

是仅仅将普通的lambda表达式强制转换为强类型的委托,还是有更多的表达式.

我很清楚一个强类型的代表就像跟随

UpdateTextDelegate mydelegate = new UpdateTextDelegate(MethodName)
Run Code Online (Sandbox Code Playgroud)

足够作为类型的参数System.Delegate,但匿名方法的想法对我来说是新的.

c# lambda delegates anonymous-methods

17
推荐指数
2
解决办法
1万
查看次数

标签 统计

c# ×2

anonymous-methods ×1

delegates ×1

expression ×1

lambda ×1

methods ×1