I came across some code like this:
Dim results = From item In New List(Of Integer) From {1, 2, 3}
Select item
Select item
I am surprised that Select item
twice is legal. It seems to behave exactly the same as if there was only one Select
line. I tried converting to C# and it produces a compile error.
Is there any reason to use multiple Selects? Could this ever cause the query to behave differently?
the C# equivalent syntax would be :
var results = from item in new List<int> {1, 2, 3}
select item into item
select item;
That way you create a new scope to "chain" queries or quoted from the VB.Net documentation (see links) The Select clause introduces a new set of range variables for subsequent query clauses (you can see the into C# keyword documention or the Select VB.Net clause documentation for further information and examples)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With