OK ... rather trivial question here ...
I have a member level Hashtable. In my test, I've created an ArrayList in the Form_Load event and populated it with three string values. I then add the ArrayList in my Hashtable using the string "First" as the key value.
I have a second event in my class, Button1_Click. In that event, I would like to retrieve the ArrayList from the Hashtable into a new local object ArrayList, then iterate through those values.
I have successfully populated the Hashtable, and gotten as far as determining the value in the hashtable is an ArrayList in the OnClick event. I'm experiencing problems trying to set the new array to the array from the Hashtable.
Clear as mud? Here's my code. I hope this helps.
//member level variable
private Hashtable htTest;
private void Form1_Load(object sender, System.EventArgs e)
{
ArrayList alTest = new ArrayList();
htTest = new Hashtable();
alTest.Add ("One"
alTest.Add ("Two"
alTest.Add ("Three"
htTest.Add ("First", alTest);
}
private void button1_Click(object sender, System.EventArgs e)
{
IDictionaryEnumerator enTest;
ArrayList alNumbers;
if(htTest.Count > 0)
{
enTest = htTest.GetEnumerator();
while(enTest.MoveNext())
{
if(enTest.Value is System.Collections.ArrayList)
//Here's where I'm having problems. There's no ".ToArray"
//method associated with the .Value of the IDictionaryEnumerator
alNumbers = enTest.Value;
{
}
}
I have a member level Hashtable. In my test, I've created an ArrayList in the Form_Load event and populated it with three string values. I then add the ArrayList in my Hashtable using the string "First" as the key value.
I have a second event in my class, Button1_Click. In that event, I would like to retrieve the ArrayList from the Hashtable into a new local object ArrayList, then iterate through those values.
I have successfully populated the Hashtable, and gotten as far as determining the value in the hashtable is an ArrayList in the OnClick event. I'm experiencing problems trying to set the new array to the array from the Hashtable.
Clear as mud? Here's my code. I hope this helps.
//member level variable
private Hashtable htTest;
private void Form1_Load(object sender, System.EventArgs e)
{
ArrayList alTest = new ArrayList();
htTest = new Hashtable();
alTest.Add ("One"
alTest.Add ("Two"
alTest.Add ("Three"
htTest.Add ("First", alTest);
}
private void button1_Click(object sender, System.EventArgs e)
{
IDictionaryEnumerator enTest;
ArrayList alNumbers;
if(htTest.Count > 0)
{
enTest = htTest.GetEnumerator();
while(enTest.MoveNext())
{
if(enTest.Value is System.Collections.ArrayList)
//Here's where I'm having problems. There's no ".ToArray"
//method associated with the .Value of the IDictionaryEnumerator
alNumbers = enTest.Value;
{
}
}