将 C# Lambda 转换为 vb.net
需要帮助将其转换为 VB.NET
public void GetCustomers(Action<IEnumerable<Customer>> onSuccess, Action<Exception> onFail)
{
Manager.Customers.ExecuteAsync(op =>
{
if (op.CompletedSuccessfully)
{
if (onSuccess != null)
onSuccess(op.Results);
}
else
{
if (onFail != null)
{
op.MarkErrorAsHandled();
onFail(op.Error);
}
}
}
);
}
Need Help in converting this to VB.NET
public void GetCustomers(Action<IEnumerable<Customer>> onSuccess, Action<Exception> onFail)
{
Manager.Customers.ExecuteAsync(op =>
{
if (op.CompletedSuccessfully)
{
if (onSuccess != null)
onSuccess(op.Results);
}
else
{
if (onFail != null)
{
op.MarkErrorAsHandled();
onFail(op.Error);
}
}
}
);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用以下语法进行内联匿名函数/子函数:
有时,当您内联使用它时,事情会变得非常不稳定,因此当发生这种情况时,我会给本地子/函数一个名称:
这很有效,因为您仍然可以关闭您的词法环境。
这全是我的记忆——我家里没有 VS(而且我尽量不在工作中恶搞)。特别是,我不确定我的右括号是否放在正确的位置。
MSDN 参考
You can do in-line anonymous functions/subs with syntax like:
Sometimes things get really flakey when you use it inline, so when that happens I give the local sub/function a name:
This works well because you can still close over your lexical environment.
This is all from memory - I don't have VS at home (and I try not to troll SO at work). In particular, I'm not sure I have my closing paren in the right place.
MSDN Reference