|
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,
(comments are locked)
|
The difference is that Add won't add a property that already exists; the other way overwrites it. 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?
Feb 27 '12 at 06:49 AM
dansav
You can use type Object to have the value be any type, though you have to cast it to the correct type when retrieving it.
Feb 27 '12 at 07:32 AM
Eric5h5
(comments are locked)
|
