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
轉換。IOrderedEnumerable到vb.net IOrderedEnumerable轉換
我知道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 Each group As var In beeGroups
'我絕對堅持這個錯誤在C#項目轉化爲vb.net'什麼錯誤到底是什麼? – mclark1129