【发布时间】:2015-06-08 14:28:09
【问题描述】:
Private Sub UpdateListBox(message As String)
Dim beeGroups As IOrderedEnumerable(Of IGrouping(Of BeeState, Bee)) = From beeGroup In From bee In Me.world.BeesGroup bee By bee.CurrentStateOrder By beeGroup.KeybeeGroup
Me.listBox1.Items.Clear()
For Each beeGroup As IGrouping(Of BeeState, Bee) In beeGroups
Dim s As String
s = If(beeGroup.Count() = 1, String.Empty, "s")
Me.listBox1.Items.Add(Convert.ToString(beeGroup.Key) & ": " & beeGroup.Count() & " bee" & s)
If beeGroup.Key <> BeeState.Idle OrElse beeGroup.Count() <> Me.world.Bees.Count() OrElse Me.framesRun <= 0 Then
Continue For
End If
Me.listBox1.Items.Add("Simulation ended: all bees are idle")
Me.toolStripButtonStartSimulation.Text = "Simulation ended."
Me.statusStrip1.Items(0).Text = "Simulation ended"
Me.timer1.Enabled = False
Next
End Sub
在将c# 项目转换为vb.net 时,我完全陷入了这个错误。
我知道c#是这样的
IOrderedEnumerable<IGrouping<BeeState, Bee>> beeGroups = from bee in this.world.Bees
group bee by bee.CurrentState
into beeGroup orderby beeGroup.Key select beeGroup;
但一旦转换为vb.net,它会尝试用最少的声明在一行上声明所有内容。
在c# 中,您也可以逃脱
c#:
foreach (IGrouping<BeeState, Bee> beeGroup in beeGroups)
vb.net 尝试在自身内部声明 for 语句:
For Each group As var In beeGroups
【问题讨论】:
-
I'm absolutely stuck at this error in the conversion of a c# project to vb.net究竟是什么错误?
标签: c# asp.net .net vb.net iorderedenumerable