Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't declare lists in VB.NET?

Tags:

vb.net

Dim lstNum As New List(Of Integer)(New Integer() { 3, 6, 7, 9 })

When I type the above line of code, Visual Studio informs me of an error

'Microsoft.Office.Interop.Word.List' has no type parameters and so cannot have type arguments.

What on earth does that mean and how do I fix it? I can't seem to create lists of any kind. I'm assuming I'm missing some sort of import but I'm not fluent with VB.Net enough to know what to try.

like image 685
redhotspike Avatar asked Dec 16 '22 16:12

redhotspike


2 Answers

Use Generic.List instead of just List.

Dim lstNum As New Generic.List(Of Integer)(New Integer() { 3, 6, 7, 9 })

Since you have the Word interop imported, it is trying to find Word.List. Specifying Generic.List will tell it to go outside of that import.

like image 59
David Brunow Avatar answered Jan 07 '23 15:01

David Brunow


Try adding System.Collections.Generic

 Dim lstNum As New System.Collections.Generic.List(Of Integer)(New Integer() { 3, 6, 7, 9 })
like image 44
Emmanuel N Avatar answered Jan 07 '23 14:01

Emmanuel N