Sometime back, I had written a post to Generate Odd Numbers within a Range using LINQ. Here’s a small modification to use LINQ to generate float numbers within a Range say - 20 to 40.
static void Main(string args)
var rng = Enumerable.Range(200, 200).Select(x => x / 10f);
foreach (float n in rng)
VB.NET (Converted Code)
Dim rng = Enumerable.Range(200, 200).Select(Function(x) x / 10f)
For Each n As Single In rng
As you know, the Enumerable.Range accepts two parameters: Start and Count. Since we are dividing the numbers in the range by 10F, the numbers gets generated in the following manner:
200/10 = 20 ; 201/10 = 20.1 ; 202/10 = 20.2
and so on..
Giving me +1 tells me you liked this article! Thanks in advance