任何人都可以提供匿名方法和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,但匿名方法的想法对我来说是新的.
我正在使用FB.getLoginStatus()检查登录,如果需要,将显示授权对话框.
在这种情况下,如果用户从下面的屏幕取消选中电子邮件,屏幕将不会尝试通过显示对话框重新询问用户,并且调用FB.login将导致警告用户已经过身份验证.有一种方法我可以通过recheck选项传递范围FB.getLoginStatus()?或任何其他解决方案,让我走上正轨
function checkLoginState() {
FB.getLoginStatus(function (response) {
//console.log('statusChangeCallback');
//console.log(response);
if (response.status === 'connected') {
// Logged into your app and Facebook.
LogUserIn();
} else if (response.status === 'not_authorized') {
//console.log('you must authorize the app');
alert(message);
} else {
//console.log('Please log into Facebook.');
}
});
}
Run Code Online (Sandbox Code Playgroud)
