Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a hashtable where I have added something into it.

 

hastht.Add(no, new object[2]{class, command}

 

IDictionaryEnumerator myEnumerator = cmdqueue.GetEnumerator();

myEnumerator.MoveNext();

_key = myEnumerator.Key;

 

_value = myEnumerator.Value;

 

 

The _value contains class and command that I wish to get, but if I try

 

object[] xxx = (object[])_value;

 

I get the error that the cast is invalid. How do I solve this !

  • Administrators
Posted

If you step through this in a debugger what is the value of _value when you get the error?

 

Also storing object arrays inside a HashTable is probably not going to win any 'Best OO Practices' awards, if you give a bit more detail about what you are trying to do there may be a better / easier way to handle the problem

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

the object _value is

[0]

[0] class

[1] command

 

Please let me know what you would suggest to follow the 00 Practices.

This is what I have to do:

 

I have a device that can sleep and later wake up. When I ask the device to operate a command and it is sleeping, I want to save its number, it class and command, so that when it later wakes up it reads from the hashtable or whatsoever to fullfill the command.

 

How would you suggest me to do that ?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...