0

When I tried to add this property in one of class file i'm getting error.

Friend Property StatusesCollection() As New Collection(Of Status)

In this the status is a collection of properties.The error is thrown in the Status.

Error:

 Microsoft.visualbasic.collection has no type parameters an so cannot have type arguments
A Coder
  • 3,039
  • 7
  • 58
  • 129

2 Answers2

2

You have a reference to Microsoft.VisualBasic in your project which contains a Collection class. This is what the compiler thinks you are trying to use and throws your error because it is not a generic type.

However what you are trying to use is the Generic Collection object Collection(Of T) which is in the System.Collections.ObjectModel namespace.

Easiest solution is to reference the fully qualified name so that the class is no longer ambiguous. Change:

Friend Property StatusesCollection() As New Collection(Of Status)

to

Friend Property StatusesCollection() As New System.Collections.ObjectModel.Collection(Of Status)

Or use a List(Of T) instead:

Friend Property StatusesCollection() As New List(Of Status) 

See this question for a comparison: What is the difference between List (of T) and Collection(of T)?

Community
  • 1
  • 1
Matt Wilko
  • 26,994
  • 10
  • 93
  • 143
0

Try adding this.

Imports System.Collections.ObjectModel
A Coder
  • 3,039
  • 7
  • 58
  • 129
  • For reference the `Collections.ObjectModel` has a zero-based index, compared to the usual Collection that has a 1-based index So it might not be a drop in replacement depending on if indexes is used or not. – NiKiZe Aug 06 '16 at 08:00