Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Storing array object in hash table

Status
Not open for further replies.

chebbi

Programmer
Feb 6, 2002
98
IN
Hi
I want to store array object in hash table and then create application variables based on values in the array. Iam uanble to store array object in hash table.

My code is

Manager.Add("AUserManager",AUserManager);
IDictionaryEnumerator myHashEnumerator = Manager.GetEnumerator();
while ( myHashEnumerator.MoveNext() )
{
for ( int j=0; j<=myHashEnumerator.Value.ToString().Length-1; j++ )
{
Application.Add(myHashEnumerator.Key.ToString()+&quot;[&quot; + j + &quot;]&quot;,myHashEnumerator.Value+&quot;[&quot;+ j +&quot;]&quot;);
}
}

when i retreive this application variable iam getting it as System.String[][1].

So the array is passed as string object. Any ideas?

Badrinath Chebbi
 
I'll take a stab at this...

Here is the problem:

Code:
Application.Add(myHashEnumerator.Key.ToString()+&quot;[&quot; + j + &quot;]&quot;,myHashEnumerator.Value+&quot;[&quot;+ j +&quot;]&quot;);

You are calling .ToString() too early. You first need to get the object out of the array and then you can cast it to it's original type.

Maybe...

Code:
Application.Add((string)myHashEnumerator[j].Key, (string)myHashEnumerator[j].Value);


Regards
[pipe]




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top