Results 1 to 7 of 7

Thread: Does 'collection' means like an array?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2003
    Posts
    436

    Does 'collection' means like an array?

    any special benefits in using 'collections' rather than using 'arrays'?

    thanks

  2. #2
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    Arrays are dying in .NET...They are being replaced by Dictionary Objects.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  3. #3
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    A collection is not far removed from an array. There are numerous objects that inherit or implement ICollection and thus could be considered collections like ArrayList. Generally speaking collections differ from arrays in that they are easier to manipulate or add/remove items from.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2003
    Posts
    436

    array are 'dying"???

    That's surprising....
    I just started on a project and I am using arraylist heavily...

    I hope you didn't mean arraylist ..

    nath

  5. #5
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Reading, UK
    Posts
    870
    what's the difference between a dictionary object and a collection?
    www.vb-tech.com
    .Net Freelance Development
    http://weblog.vb-tech.com/nick
    My blog

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by bnathvbdotnet
    That's surprising....
    I just started on a project and I am using arraylist heavily...
    I hope you didn't mean arraylist ..
    nath
    Don't worry , ArrayList is perfect solution over array . I had to use it in a way that holds 10,000 values in one arraylist and working nice . Performance is good too . faster in iteration and retrieving .

  7. #7
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780
    Originally posted by nswan
    what's the difference between a dictionary object and a collection?
    A collection is a type of dictionary object, there are many others such as sortedlists, arraylists, queues. They are a fundamental thing to learn, so get reading, there are 100s of examples.

    There is also a vb.collection, which is different from the dictionary object set. Its easier to use, but slower.

    Be warned tho, the hashtable in .net2002 (being framework 1.0) has a memory problem. Its ok until you add 100,000s of objects every hour for days.

    Heres a snippet of code that uses the dictionary base object and acts exactly like the VB.Collection, it automatically changes the objects to the correct type when reading. Use the

    For each Thing in MyNewCollection.Values << note the extra part to loop through.

    Code:
    <Serializable()> Friend Class MyCollection : Inherits Collections.DictionaryBase
    
        Friend Sub Add(ByVal ClassRef As clsMyClass, Optional ByVal Key As String = "")
            MyBase.Dictionary.Add(Key, ClassRef)
        End Sub
    
        Friend Sub Remove(ByVal Key As String)
            MyBase.Dictionary.Remove(Key)
        End Sub
    
        Friend Function Item(ByVal Key As String) As clsActionsExpand
            Return DirectCast(MyBase.Dictionary.Item(Key), clsMyClass)
        End Function
    
        Public ReadOnly Property Values() As ICollection
            Get
                Return InnerHashtable.Values
            End Get
        End Property
    
    End Class

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width