Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleInitialize an array with a range of values or a repeated value in Visual Basic .NET (version 2008 or later)
DescriptionThis example shows how to initialize an array with a range of values or a repeated value in Visual Basic .NET (version 2008 or later).
Keywordsinitialization, initialize array, range, repeated values, VB.NET, Visual Basic .NET, Visual Basic 2008
CategoriesTips and Tricks, VB.NET
 
The Enumerable class provides shared methods that can initialize an array to a range of values or a repeated set of values. When the program starts, it uses the following code to make an array holding the values 101 through 120 and a second array holding 20 entries all set to 13. It sets the DataSource of two ListBoxes to these arrays so you can see the values.
 
Dim range_values() As Integer
range_values = Enumerable.Range(101, 20).ToArray()
lstRange.DataSource = range_values

Dim repeat_values() As Integer
repeat_values = Enumerable.Repeat(Of Integer)(13, _
    20).ToArray()
lstRepeat.DataSource = repeat_values
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated