Collection Declaration

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

This may sound like a simple question but in VB.NET you can declare a
Collection as
public MyCollection As Collection

How could you write the same declaration in C#?
 
VB.NET's collection object is unique to VB.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vaobjcollectionpme.asp

The only equivalent is to import the VisualBasic namespace and use it
directly from C#, which some purists might frown upon (but I say go ahead.)

Otherwise you'd probably choose a similar (but slightly different) structure
such as a HashTable or Arraylist, or something else from the Collections
namespace:
http://msdn.microsoft.com/library/d...frlrfsystemcollectionsarraylistclasstopic.asp
 
Collection in this sense is a VB.NET specific collection class. VB.NET provides
several helper classes on top of what the .NET runtime provides. I'd sugest
not using these, and instead use the collections that the CLR provides, such
as ArrayList. This way there's less confusion when sharing this collection
with other languages in .NET.

-Brock
DevelopMentor
http://staff.develop.com/ballen
 
Back
Top