Collections.. Help

  • Thread starter Thread starter VB
  • Start date Start date
V

VB

I want to create collection that uses two keys to retrieve the value.

Here is what I am trying to do..

I want to read XML document like this below to memory into collection
object on startup.

<Measures>
<Module Name="Module1">
<Measure Name="Measure1" Format="Currency">
<Measure Name="Measure2" Format="Number">

</Module>
<Module Name="Module2">
<Measure Name="Measure1" Format="Percent">
<Measure Name="Measure2" Format="Number2">
</Module>
</Measures>

My collection object should implement Dictionary object to retrive
measure format by key something like below

measures["Module1","Measure1].Format

I know how to do this by just one key. Is anybody how to do this using
Collections that uses two keys to retrive the value?

Thanks
 
Hi,

The simplest way is to use unique separator and join two keys into
single. To work with key-value use the classes with IDictionary
implemented (e.g. Hashtable).

The better way is to define two collections:
1) main *Measure* collection
- indexer: public MeasureItem this[string key1, string key2] {get;}

2) sub *Measure* collection
- indexer: public MeasureItem this[string key2] {get;}

.... and class:
3) *MeasureItem* class
- property: public object Format { get };

Regards

Marcin
 
Back
Top