Array type

  • Thread starter Thread starter Maziar Aflatoun
  • Start date Start date
M

Maziar Aflatoun

Hi everyone,

Is there a type of array that would do the follow?
Store key/value pair
Return the current index in the array for a key or value?

BTW, I also need to bind it to a dropdown list .

Than you
Maz.
 
I have seen this but as far as I know it doesn't let me find out the array
index. For example search for a key or value and returning the index number.
Any idea?

Thanks
Maz.
 
Yes, the hashtable won't work well for your needs.

You'll have to create your own custom collection either by inheriting
CollectionBase, or since you have similar needs as a HashTable and Arraylist
from one of those two.

Karl
 
I have seen this but as far as I know it doesn't let me find out the array
index. For example search for a key or value and returning the index number.
Any idea?

Thanks
Maz.

Is this what you're looking for?


// here's the Name/Value structure

public struct NameValue
{
private string theName;
private int theValue;

public NameValue(string aName , int Id)
{
theName = aName;
theValue = Id;
}
public string getName
{
get {return theName;}
}

public int getValue
{
get {return theValue;}
}
}

// then when I use it:

System.Collections.ArrayList theList = new ArrayList();

while (something)
{
int aVal;
string aName;

aVal = x;
aName = y;

theList.Add(new NameValue(aName, aVal));
}


Is that what you're looking for? (I use this kind of code to initialize
DropDownList controls from s datastore.)


-- ipgrunt
 
I have seen this but as far as I know it doesn't let me find out the array
index. For example search for a key or value and returning the index number.
Any idea?

Thanks
Maz.
Sorry that was a last thing, skim read, I'm a tosser cockup and a
half.
 
Back
Top