Im using the .NET framework 1.1 and Im hoping someone could help me implement a dynamic array of objects?
A watered-down example of the object I wish use is below.
Class CarObj
{
public string CarName;
public string CarYear;
}
Should I use an ArrayList or do you think it would be better to make a CarList class to implement an IList interface? Is there a performance benefit for one over another?
If you are using 1.1 and need a dynamic array style collection then ArrayList
is the best choice to get you moving.
I do hate all of the casting that comes with using ArrayList
though and I certainly don't fault people for writing custom collections that have strongly implemented members in 1.1. However if you do go this route I would suggest using a custom generator vs. tedious hand coding. There are several available that can quickly be found via google
This link for example will actually generate the code for you on the website and it can be simply copy and pasted into your project.
Inherit CollectionBase
instead; this wraps IList
and allows you to provide your own implementation of typed methods you need. This is what it's designed for :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With