在C#中,
在VB中,翻译后的代码无法编译。
(new Action(() => MessageBox.Show("Hello"))).BeginInvoke(null, null);
在VB中,翻译后的代码无法编译。
(New Action(Sub() MessageBox.Show("Hello"))).BeginInvoke(nothing, nothing)
但在VB中,我可以将BeginInvoke的结果设置为隐式变量a
并运行(感谢@Ric在另一篇帖子中提出的建议)
Dim a = (New Action(Sub() MessageBox.Show("Hello"))).BeginInvoke(Nothing, Nothing)
但是现在我想知道为什么在这种情况下VB需要在左侧设置某些内容,而C#不需要。
Call
(而不是dim a =
),它能编译吗? - J. SteenNew Random().Next()
也会出错。 - Jon Skeet