Jedhi Posted January 20, 2006 Posted January 20, 2006 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 ! Quote
Administrators PlausiblyDamp Posted January 20, 2006 Administrators Posted January 20, 2006 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 Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Jedhi Posted January 21, 2006 Author Posted January 21, 2006 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 ? Quote
Administrators PlausiblyDamp Posted January 21, 2006 Administrators Posted January 21, 2006 Why don't you create a class that holds both a class and a command (plus any other information required) and store these in the HashTable? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.