1

I'm getting an "end of statement expected" error on the following code:

Public BlockedID As New List(Of String) From {"0", "2", "3", "4", "5", "6"}

The code works fine on my nephew's version of Visual studios so I assume it's a VB.net framework specific problem. I already changed the target framework to 3.5 to get rid of some other errors.

Any idea how I can fix this one?

dlofrodloh
  • 1,728
  • 3
  • 23
  • 44
  • It's totally fine and compiles. Are you sure that's the line compiler complains about? – MarcinJuraszek Sep 07 '13 at 16:22
  • 2
    possible duplicate of [vb.net Object Initialiser List(Of T)](http://stackoverflow.com/questions/3254169/vb-net-object-initialiser-listof-t): **introduced in VB.Net 2010** – Chris Sep 07 '13 at 16:25
  • Yeah, it's the line. It underlines the From {"0", "2", "3", "4", "5", "6"} part as being the problem. – dlofrodloh Sep 07 '13 at 16:26
  • Ok the problem in the link provided is probably the issue as I'm running VisualStudios 2008. Now when I try Public BlockedID() As String BlockedID(0)="0" BlockedID(1)="2" BlockedID(3)="3" BlockedID(4)="4" BlockedID(5)="5" BlockedID(6)="6" I'm getting a "declaration expected" error? – dlofrodloh Sep 07 '13 at 16:53

1 Answers1

1

Try this instead:

Public BlockedID As New List(Of String)({"0", "2", "3", "4", "5", "6"})
Victor Zakharov
  • 25,801
  • 18
  • 85
  • 151