C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Argument 1: The first argument to Enumerable.Range is the starting number. This can be positive or negative. Here we use 6.
Argument 2: The second argument to Enumerable.Range is the number (count) of values we want to have in the resulting array.
VB.NET program that uses Enumerable.Range, For Each
Module Module1
Sub Main()
Dim range As IEnumerable(Of Integer) = Enumerable.Range(6, 4)
' Display the range.
For Each number As Integer In range
Console.WriteLine("RANGE ELEMENT: {0}", number)
Next
End Sub
End Module
Output
RANGE ELEMENT: 6
RANGE ELEMENT: 7
RANGE ELEMENT: 8
RANGE ELEMENT: 9
Argument 1: This is the value we want to have repeated. In this example, we like the number 3, and want many copies of it.
Argument 2: This is the repetition count. So by passing the value 4 as the second argument, we get 4 repeated numbers.
VB.NET program that invokes Repeat
Module Module1
Sub Main()
' Repeat the number 3 four times.
For Each number As Integer In Enumerable.Repeat(3, 4)
Console.WriteLine("REPEAT: {0}", number)
Next
End Sub
End Module
Output
REPEAT: 3
REPEAT: 3
REPEAT: 3
REPEAT: 3
VB.NET program that uses Enumerable.Empty
Module Module1
Sub Main()
Dim empty As IEnumerable(Of String) = Enumerable.Empty(Of String)()
' Count the empty collection.
Console.WriteLine("EMPTY COUNT: {0}", empty.Count())
End Sub
End Module
Output
EMPTY COUNT: 0