471,627 Members | 2,336 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,627 software developers and data experts.

appropriate collection class

hi,
suppose in my application i need to perform a lot of
insertions and deletions on my data structure.
the ideal data structure in this scenario would be a linked list.
unlike java, c# does not have a built-in "LinkedList" class.
so which collection class should i use in C#?

regards,
kiran
Feb 6 '06 #1
2 1098
It depends on what type of information you wish to hold in your
collection.

If you have a collection of objects or structs, I would suggest an
ArrayList (System.Collections.ArrayList) since you can store objects
within an array list. If you are using .NET Framework 2.0, then use
generics with an ArrayList so you dont have to box/unbox your objects.

If it isnt a collection of objects you could use a HashTable if you
need to store a specific key value (like a Primary Key value for
instance)

Then even further down than that, if you just want to store string
values, you could use a string array.

There is multiple options here, it all depends on how you will be
representing the data in your business logic. I personally try to use
structs/classes as much as possible, because this allows me to not only
store the data, but also additional business rules within the classes
that may pertain to my business logic. It just makes it easier and more
modularized.

For more info look into the System.Collections namespace, as there is
alot more options than what I have mentioned here.

Feb 6 '06 #2

"Kiran A K" <ki*****@trigent.com> wrote in message
news:Ov*************@TK2MSFTNGP09.phx.gbl...
hi,
suppose in my application i need to perform a lot of
insertions and deletions on my data structure.
the ideal data structure in this scenario would be a linked list.
unlike java, c# does not have a built-in "LinkedList" class.
so which collection class should i use in C#?


Without knowing precisely what you are doing and if it is a performance
problem or just a nagging issue, I can't say for sure. Like DKode said
ArrayList or a Hashtable is fine, if you aren't in need of top line
performance. If performance is going to be an issue, LinkedLists are pretty
easy to write, just write one.
Feb 6 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Marc L'Ecuyer | last post: by
reply views Thread by Sundown | last post: by
5 posts views Thread by Kurt Bauer | last post: by
19 posts views Thread by Jamey Shuemaker | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.