Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

Array or...?

Let's say I have a bunch of string pairs (oh I dunno - how about names and phone numbers) that I want to sort/iterate based on both 'fields' (eg. a multi-element 'key'). I can do this with an ArrayList and IComparer, or I could go the ADO.NET DataSet route. Is there an obvious nth option? Which is best?

.NET Neophyte
Tuesday, September 14, 2004

You might want to consider Hashtable as well.

<-.->
Tuesday, September 14, 2004

Hashtable isn't a good choice for obvious(?) reasons.

The simplest way to achieve what you want is probably a collection class based on an ArrayList. 

Simplest = best in most cases: only go the DataSet route if you want all the additional features of a DataSet.

Joe
Tuesday, September 14, 2004

Thank you... also, is it my imagination or does (the 1.1) DataSet only support a single key (eg. there is a DataSet.PrimaryKey property, I need multiple keys). (Not multiple columns in the PK, yes I see how it does that).

.NET Neophyte
Tuesday, September 14, 2004

The DataTable class has a PrimaryKey, but you can use DataViews to sort and filter the data.

Joe
Tuesday, September 14, 2004

how about one of the specialized string collections which have all this functionality built in?

mb
Tuesday, September 14, 2004

*  Recent Topics

*  Fog Creek Home