I have the Vb code below i would like to know why it is failing at i. I have done this is C# and it works fine.
Dim numbers = Enumerable.Range(1, 4).OrderBy(i >= ran.Next()).ToList()
I have the Vb code below i would like to know why it is failing at i. I have done this is C# and it works fine.
Dim numbers = Enumerable.Range(1, 4).OrderBy(i >= ran.Next()).ToList()
Because that is not valid syntax in VB.NET, you need the ugly Function
keyword:
Dim numbers = Enumerable.Range(1, 4).OrderBy(Function(i) i >= ran.Next()).ToList()
In VB.NET i almost always try to avoid that keyword, it hurts my eyes. So you can use this:
Dim numbers = From n In Enumerable.Range(1, 4)
Order By n >= ran.Next()
Dim numList As List(Of Int32) = numbers.ToList()
But if you want to order randomly this should work:
Dim numbers = From n In Enumerable.Range(1, 4)
Order By ran.Next()
Dim numList As List(Of Int32) = numbers.ToList()