473,729 Members | 2,142 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 multidimensiona l 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 1461
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.s i> 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 multidimensiona l 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.s i> 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 multidimensiona l 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******@skyne tWORK.be> wrote in message
news:eG******** ******@tk2msftn gp13.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.s i> 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 multidimensiona l 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 StringDictionar y class. Otherwise
you're best of using an ArrayList.

Yves

"Saso Zagoranski" <sa************ *@guest.arnes.s i> 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******@skyne tWORK.be> wrote in message
news:eG******** ******@tk2msftn gp13.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.s i> 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 multidimensiona l 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
2850
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. //------------------------------------------------------------------------- import java.io.*; import java.util.*;
10
2030
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 good.. not there in VB.net?? 2. Some language features of VB.Net like Redim(makes it easier for developers), but not good enough reason. 3. C# is in more like standard languages and key words used are more
21
3918
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 table1"; var obj=new ActiveXObject("ADODB.Recordset");
2
1536
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 at the same time be able to reference the item in the collection by key? I know that combo box data source must be an IList but with IList I can't reference the object with the key. Can this be done in VB.Net? Thanks for any ideas,
5
1894
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 has 4 fields with these types: type field name ============ integer recordID
13
1427
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 common interface I would be able to invalidate and unload old information as it is updated (Removing the item from the collection?) My big question is what collection class will give me the greatest flexibility and greatest performance? I hope...
4
9695
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 writing the JavaScript doesn't have to pass the index in the "onChange" event name. I thought that one might be able to use "this.value" or compare this as
4
1651
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" ; } but in the interest of scaleability, I want this program to store the label values in a collection, access them via Next() and cycle back to
13
1972
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 gui thread. What pattern should I be using now I'm upgrading to .net 2.0? APM, async delegates and BeginInvoke or Thread.Start etc...? Should I be creating a single thread manulally (or using threadpool) and and setting the polling on an...
0
8913
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
9200
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9142
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8144
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6016
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2162
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.