This code makes little sense; you add hard-coded
immediate constant like 8533, miss the type cast, and so on. You don't understand strong typing. You could type-cast
objhashmap[key]
:
ADXVoice obj = (ADXVoice)objhashmap[key];
which is possible if
runtime type is
assignment-compatible with the type to be cast to. In your code sample, you show adding the value of the type
ADXVoice
, so, for this value, the typecast will be successful. But why doing so?
Don't use those obsolete non-generic (non-specialized) collection types. Use, for example,
System.Collections.Generic.Dictionary<int, ADXVoice>
:
http://msdn.microsoft.com/en-us/library/xfhwa508%28v=vs.110%29.aspx[
^].
You need to learn inheritance,
compile-time types vs
runtime types and other basic OOP ideas, as well as generics.
—SA