Reputation: 18859
I'm simply trying to create an array of integers:
Dim amenities() as Integer
amenities=New Integer(){1,2,3,4,5}
And I'm getting this error:
Expected end of statement
Dim amenities() as Integer
-----------------------^
It says the error is happening on "as", but I have no idea what I'm doing wrong. I feel stupid asking, but I'm stuck.
Upvotes: 1
Views: 17525
Reputation: 13303
I tested your code using VS2010 and targeting Frameworks 2.0, 3.0, 3.5 and 4.0 and in all cases your code works:
Module Module1
Sub Main()
Dim amenities() As Integer
amenities = New Integer() {1, 2, 3, 4, 5}
End Sub
End Module
In fact this syntax is also valid:
Dim amenities As Integer()
amenities = New Integer() {1, 2, 3, 4, 5}
But if you want to 1 line your code you need the first syntax:
Dim amenities() As Integer = {1, 2, 3, 4, 5}
Upvotes: 2
Reputation: 164281
Amenities is the variable name. So your declaration should read:
Dim amenities as Integer()
Upvotes: 3