I’m trying to use Dictionary instead of Hashtable. I’m having trouble finding any examples of how I would use this in unity javascript. Previously I would do this
myHash=new Hashtable();
myHash[“propertyname”]=“something”;
How would I do this using Dictionary?
var myHash = new Dictionary<string, string>();
myHash.Add(“propertyname”, “something”);
or can I do
openWith[“txt”]=“notepad.exe”);
Thanks,
key,value both have to be strings in this example. In the unity hashtable the value part could be any type -- I thought that's why it was useful. Is there some way to make the value be anything you want ie. int, string, array? using Dictionary instead of Hashtable?
– dansavYou can use type Object to have the value be any type, though you have to cast it to the correct type when retrieving it.
– Eric5h5