473,386 Members | 1,796 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

ArrayList or List<>

Hello,
I would like to know what is better for data binding and serialization
purposes ArrayList or List<? Thank you!

*** Sent via Developersdex http://www.developersdex.com ***
Nov 26 '07 #1
2 1881
In both cases List<T>.
More importantly, you get compile-time safety and intellisense on your
code, which is worth quite a bit.

For binding:
The way the component-model detects the meta-data is complex; first,
it will detect collections via IListSource or IList (for the former it
just calls GetList() and ends with the latter). It then checks the
IList for ITypedList (to provide custom metadata), then if that isn't
implemented it checks for a "public Foo this[int index] {get;}"
indexer (for some Foo). If this is supported it uses the type of Foo
for the metadata. Failing that, it checks if the list has contents; if
it dose, it uses the first (index 0) item in the list to describe the
metadata. Finally it panics. (there is also specific handling of
arrays; probably immediately before the ITypedList check).

List<Twill therefore provide correct metadata (for type T) even when
the list is empty. ArrayList cannot.

For over-the-wire serialization, List<Tgives it at least a fighting
chance of providing schema metadata.

Marc
Nov 26 '07 #2
Marc Gravell wrote:
List<Twill therefore provide correct metadata (for type T) even when
the list is empty. ArrayList cannot.

For over-the-wire serialization, List<Tgives it at least a fighting
chance of providing schema metadata.
Also, for binding purposes, there is BindingList<Tthat relieves a lot
of headaches. List<Tdoesn't update things like ListView when its data
changes, so some events don't fire properly, whereas BindingList<Tdoes.

Just throwing that out there because I've run into it a couple of times.
Chris.
Nov 27 '07 #3

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

Similar topics

4
by: matty.hall | last post by:
I have two classes: a base class (BaseClass) and a class deriving from it (DerivedClass). I have a List<DerivedClass> that for various reasons needs to be of that type, and not a List<BaseClass>....
0
by: Iron Moped | last post by:
I'm airing frustration here, but why does LinkedList<not support the same sort and search methods as List<>? I want a container that does not support random access, allows forward and reverse...
7
by: Andrew Robinson | last post by:
I have a method that needs to return either a Dictionary<k,vor a List<v> depending on input parameters and options to the method. 1. Is there any way to convert from a dictionary to a list...
44
by: Zytan | last post by:
The docs for List say "The List class is the generic equivalent of the ArrayList class." Since List<is strongly typed, and ArrayList has no type (is that called weakly typed?), I would assume...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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,...

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.