silverllight中()=>的用法是什么(what is the use of ()=> in silverllight)

编程入门 行业动态 更新时间:2024-10-28 11:23:59
silverllight中()=>的用法是什么(what is the use of ()=> in silverllight)

你能说什么()=>和=>的用法吗? 我在代码中看到了这一点。 我没有得到任何参考。

this.Dispatcher.BeginInvoke(()=> { //some thing.. };

Can you say what is the use of the ()=> and =>? I saw this in a code. I did not get any reference for this.

this.Dispatcher.BeginInvoke(()=> { //some thing.. };

最满意答案

这个符号是不带参数的lambda表达式的符号。 如果lambda表达式使用参数,它们将在空括号中声明,如说...

this.Dispatcher.BeginInvoke((x, y) => { do some' with x and/or y }, 12, somevar);

简而言之,lambda表达式允许在需要的地方创建“无名称”函数。 在问题的例子中, BeginInvoke()方法要求它的第一个参数是委托(一个“指向方法的指针”),这正是lambda表达式提供的。

This notation is that of a lambda expression which takes no argument. If the lambda expression made use of arguments they would be declared in the empty set of parenthesis as in say...

this.Dispatcher.BeginInvoke((x, y) => { do some' with x and/or y }, 12, somevar);

In a nutshell, lambda expressions allows creating "nameless" functions, right where they are needed. In the example of the question, the BeginInvoke() method requires its first parameter to be a delegate (a "pointer to a method"), which is exactly what this lambda expression provides.

更多推荐

本文发布于:2023-07-23 22:34:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1238193.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:silverllight

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!