|
-
Dec 1st, 2003, 03:30 PM
#1
Thread Starter
Hyperactive Member
Does 'collection' means like an array?
any special benefits in using 'collections' rather than using 'arrays'?
thanks
-
Dec 1st, 2003, 04:32 PM
#2
Frenzied Member
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
-
Dec 1st, 2003, 05:04 PM
#3
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.
-
Dec 1st, 2003, 07:54 PM
#4
Thread Starter
Hyperactive Member
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
-
Dec 2nd, 2003, 04:13 AM
#5
Fanatic Member
what's the difference between a dictionary object and a collection?
-
Dec 2nd, 2003, 05:43 AM
#6
Sleep mode
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 .
-
Dec 2nd, 2003, 08:10 AM
#7
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|