Reputation: 7880
hello
Im using VB 2008
is it possible to set array items with one line code?
for example, can i do something like:
Dim array = Array("a", "b", "c", "d")
instead of:
Dim array()
array(0) = "a"
array(1) = "b"
array(2) = "c"
array(3) = "d"
thanks
Upvotes: 6
Views: 4692
Reputation: 5247
Yes using the below format:
Dim boolArr As Boolean() = New Boolean() {True, True, False, True}
Upvotes: 1
Reputation: 7280
You can use the following to initialize an array with explicit members.
Dim array As String() = New String(){"a", "b", "c", "d"}
This can be done with any type.
Upvotes: 11