473,809 Members | 2,620 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Custom class and ArrayList

Hi,

I want to know if this is the most efficient method of fixing my
problem:

I have a custom class and I need to maintain an array of these items.
Initially I used MyCustom[] a = new MyCustom[someSize];

However, a new requirement has popped up which means this array might
change size (adding elements only) so I need to add more MyCustom clases
to my structure.
Having a "ReDim" method is far too slow, so my thinking is an ArrayList
would be the best array object:

ArrayList a = new ArrayList();

a.Add( new MyCustom() );

MyCustom handle = (MyCustom)a[i];

Anyone see any problems with this (performance is very important)

Thanks for the help in advance.

Steven

*** Sent via Developersdex http://www.developersdex.com ***
Oct 30 '06 #1
2 8561
Consider using a strongly-typed List instance. Search MSDN on "List<T>
class" for more info:

MyCustom inst1 = new MyCustom();
MyCustom inst2 = new MyCustom();

List<MyCustomar rCustom = new List<MyCustom>( );
properties.Add( inst1);
properties.Add( inst2);

foreach(MyCusto m inst in arrCustom)
{
// do stuff
}

Bill

Oct 30 '06 #2
Consider using a strongly-typed List instance. Search MSDN on "List<T>
class" for more info:

MyCustom inst1 = new MyCustom();
MyCustom inst2 = new MyCustom();

List<MyCustomar rCustom = new List<MyCustom>( );
properties.Add( inst1);
properties.Add( inst2);

foreach(MyCusto m inst in arrCustom)
{
// do stuff
}

Bill

Oct 30 '06 #3

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

Similar topics

0
1695
by: berg | last post by:
All, I am binding an ArrayList full of custom objects to an DataGrid. The property in the custom class are all public. I define a DataGridTableStyle and set the MappingName to "ArrayList". I then add a DataGridTextBoxColumn for each of the properties in my custom class which define a MappingName --> property name in class as well as header text. When I run the form, I see correct number of rows displayed, but none of the columns...
0
2237
by: Steven | last post by:
Hi, I'm creating a custom checkbox list control which will take 2 arraylists as input. (One will contain Names and other will contain 0s and 1s. 0 - uncheck 1- check). I'm able to create the checkbox list. The problem is I'm unable to raise an event when I select any of the checkboxes. Following is the code: Could you guys please help me on this issue.
2
1685
by: raymi | last post by:
Hi, I have a custom class that gets its properties dynamically from a database at runtime. Therefore I implemented the ICustomTypeDescriptor in this class and created a a custom PropertyDescriptor. The custom class also inherits from Component and therefore can be dragged on the form in the designer view. So far so good, I can bind properties from my class to textboxes etc. But when I try to bind an ArrayList containig instances of my...
5
2104
by: dlobalzo | last post by:
Hi guys, I've been reading several topics that talk about creating a custom collection to use it as DataSource of a Datagrid. But the fact is I have a class called Action and another class called Profile. In my application, the user assigns several Actions to a Profile. I thought doing this using an ArrayList of Actions and puting that as the DataSource of the Datagrid that shows the assignments. It works, but it shows every property...
6
1860
by: Whoever | last post by:
Here's what I have A custom collection: public class aUser { public string UserName { get {...} set {...} } public class UserList : System.Collection.CollectionBase { public void Add(aUser user) {...} public aUser this {...}
4
8733
by: eugenet | last post by:
Hello, I am writing a Windows Forms application using .NET Framework 2.0 and Visual Studio 2005. I would like to use Properties.Settings class to persist a collection of custom objects. For that I am creating a setting called Connections of type System.Collections.ArrayList using the Properties designer in VS.
0
1840
by: a | last post by:
I need to create an instance of a custom object 'School.Teacher' and use it in a Profile object. I'm developing a bad case of "Pretzel Logic" thinking about this. Filling the custom object 'School.Teacher' as an ArrayList creates the proper information (see aspx code below), but I'm unable to use this ArrayList in the Profile object. The aspx code below shows the attempt and error message.
0
3269
by: Jeremy Chapman | last post by:
I have included below virtually all the code to a control I'm trying to build. My issue is that an array list property in my control does not get persisted properly to the aspx page code in design time. If I type the code in the aspx manually it does get parsed correctly though. This is an example of the aspx code that gets parsed correctly. For some reason, if I changed update the Tab property of the control through the GUI at design...
2
4280
by: =?Utf-8?B?Y3Nz?= | last post by:
I am new to ASP.net webservice and have a quesiton. Is is possible to pass custom object to a web service (using VB 2005)? My custom object will look like this Public Class Myclass Public Property1 As String Public Property2 As Integer Public Property myCollection1 As Arraylist (Actually, it will be a strongly
1
1604
by: =?Utf-8?B?Q2hhcmxlcw==?= | last post by:
I'm running VS2008 & attempting to solve a problem I've encountered while developing some software for our business. Here's the basic idea...I've created a class that represents a file (with members such as file name, file location, and a string containing the files data). Each file object also contains an ArrayList of another custom object I've created--a field object (which is basically two fields--field name & field data). These...
0
9603
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10376
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10387
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
10120
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
9200
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
6881
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
5550
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
5689
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3015
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.