I have a event(from a plugin) which returns an object parameter. When printing the object in console I get System.Collections.Hashtable. So I am guessing the object is a hashtable. How can I convert the object to a hashtable, hence be able to obtain values from keys.
To convert an Object into a Hashtable, use the as keyword,
void myEvent (object obj){
var hashtable = obj as Hashtable;
// Do stuff with your Hashtable here
}
Note that if your object isn’t a Hashtable, your hashtable variable will be null, so it may be a good idea to include a null-check before you use it,
void myEvent (object obj){
var hashtable = obj as Hashtable;
if (hashtable == null){
print("It wasn't a Hashtable");
return;
}
// Do stuff with your Hashtable here
}