473,503 Members | 1,655 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

which collection to use

Hi!

I need an array-type of collection when the entries would look like:
object myObject, int myInt, string myString

Which collection should I use?
I know I could declare a multidimensional array of objects but adding and
deleting to that
array would require distribution of objects each time something was deleted
or added so
that doesn't feel like the correct approach.

Thanks,
saso
Nov 15 '05 #1
4 1447
Hi Saso,

One suggestion would be to create a custom type,
(say something like the MyEntry class shown below)
that contains the fields (In your example -
object myObject, int myInt, string myString)
that comprise the entries to be added to the collection.

You can then add/remove instances of the MyEntry class
from a collection such as the ArrayList.

public class MyEntry
{
private object _myObject;
private int _myInt;
private string _myString;

// Expose a few public properties here to
// access/modify the private fields
// ...
}

ArrayList list = new ArrayList();
list.Add(new MyEntry(myObj, myInt, myString));

You could also create a strongly typed collection
class derived from CollectionBase that could allow you to
add and remove instances of MyEntry.

Regards,
Aravind C
"Saso Zagoranski" <sa*************@guest.arnes.si> wrote in message
news:c0**********@planja.arnes.si...
Hi!

I need an array-type of collection when the entries would look like:
object myObject, int myInt, string myString

Which collection should I use?
I know I could declare a multidimensional array of objects but adding and
deleting to that
array would require distribution of objects each time something was deleted or added so
that doesn't feel like the correct approach.

Thanks,
saso

Nov 15 '05 #2
There are many types of collections. Even specialized ones. Could you
provide us with some more information like what is needed : fast adding,
fast removing, strict order, looking up if an item is in the collection
based on one of the fields you specified (which one), ...
Each collection type has it's own benefits.

Yves

"Saso Zagoranski" <sa*************@guest.arnes.si> schreef in bericht
news:c0**********@planja.arnes.si...
Hi!

I need an array-type of collection when the entries would look like:
object myObject, int myInt, string myString

Which collection should I use?
I know I could declare a multidimensional array of objects but adding and
deleting to that
array would require distribution of objects each time something was deleted or added so
that doesn't feel like the correct approach.

Thanks,
saso

Nov 15 '05 #3
I need adding, removing and searching. Nothing special really... No real
speed
requirements either.

Aravind's idea seem ok... what do you think?

"phoenix" <pa******@skynetWORK.be> wrote in message
news:eG**************@tk2msftngp13.phx.gbl...
There are many types of collections. Even specialized ones. Could you
provide us with some more information like what is needed : fast adding,
fast removing, strict order, looking up if an item is in the collection
based on one of the fields you specified (which one), ...
Each collection type has it's own benefits.

Yves

"Saso Zagoranski" <sa*************@guest.arnes.si> schreef in bericht
news:c0**********@planja.arnes.si...
Hi!

I need an array-type of collection when the entries would look like:
object myObject, int myInt, string myString

Which collection should I use?
I know I could declare a multidimensional array of objects but adding and deleting to that
array would require distribution of objects each time something was

deleted
or added so
that doesn't feel like the correct approach.

Thanks,
saso


Nov 15 '05 #4
I would create a class with the elements in it. If you would search on the
string you might want to check out the StringDictionary class. Otherwise
you're best of using an ArrayList.

Yves

"Saso Zagoranski" <sa*************@guest.arnes.si> schreef in bericht
news:c0*********@planja.arnes.si...
I need adding, removing and searching. Nothing special really... No real
speed
requirements either.

Aravind's idea seem ok... what do you think?

"phoenix" <pa******@skynetWORK.be> wrote in message
news:eG**************@tk2msftngp13.phx.gbl...
There are many types of collections. Even specialized ones. Could you
provide us with some more information like what is needed : fast adding,
fast removing, strict order, looking up if an item is in the collection
based on one of the fields you specified (which one), ...
Each collection type has it's own benefits.

Yves

"Saso Zagoranski" <sa*************@guest.arnes.si> schreef in bericht
news:c0**********@planja.arnes.si...
Hi!

I need an array-type of collection when the entries would look like:
object myObject, int myInt, string myString

Which collection should I use?
I know I could declare a multidimensional array of objects but adding and deleting to that
array would require distribution of objects each time something was

deleted
or added so
that doesn't feel like the correct approach.

Thanks,
saso



Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2831
by: maya2000 | last post by:
Hello, Below code has a problem to read a data. It seems the non-primitive data are the reason. How can I save this Map into a file, and read it later? Thanks in advance. ...
10
2015
by: KN | last post by:
I know both are pretty much the same and it comes down to personal choice. But I have to make the choice for the team. Things so far that I am considering 1. XML documentation in C# -- thats...
21
3883
by: Rabbit63 | last post by:
Hi: I want to show a set of records in the database table on the clicnt browser. I have two ways to do this (writen in JScript): 1.The first way is: <% var sql = "select firstname from...
2
1514
by: cksj | last post by:
I'm working on a VB.Net app that has State class (CA, AZ, WA...) and collection class of State. Which collection class interface can I use if want to be able to bind the collection a combo box and...
5
1875
by: Oberon | last post by:
I want to create a collection of records which will be permanently available at the application level in an ASP.NET application. How should I go about that? Lets say that the record structure...
13
1410
by: Scott Meddows | last post by:
I'm writing an NT service to provide security information enterprise wide. I would like to have all of this information cached memory if a previous request loaded it into memory. Then using a...
4
9668
by: mflll | last post by:
I am looking into the different techniques of handling arrays of edit boxes in Java Script. The first program below works fine. However, are there better ways of doing this, where the person...
4
1643
by: metaperl | last post by:
Hi, I wrote a Forms program which toggles a label each time you click it: private void button1_Click(object sender, EventArgs e) { label1.Text = (label1.Text == "hello") ? "goodbye" : "hello" ;...
13
1957
by: Dog Ears | last post by:
I've got a windows form that monitors the status of employees it polls a database every 2 seconds to fetch updates then update a underlying dataset bound to a grid using Invoke to marshal to the...
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7074
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7273
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7322
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6982
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7451
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4667
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3150
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.