sebako
1
Good Morning Guys,
Just a question about arrays and hashtables, I need to know how to get a value if I have the key, could anyone tell me that?
And one more question is:
How could I find out how often a value exists in one array?
so I have an array:
key[1] = "bla"
key[2] = "bla"
key[3] = "bla"
how to count this?
thanks to anyone.
best regards,
zemog
http://unity3d.com/support/documentation/ScriptReference/Array.html
Part you want is:
arrayvariablename.length
You can either set or get the length from this, I believe?
Are you using C#? If that´s the case, use this
myHash.ElementAt(key)
The only way is counting:
int number = 0;
for (int i = 0; i < myArray.Length; i++)
{
if (myArray[i] == value) number++;
}
tonyd
4
You access items in an array thru its index, you access items in a hashtable thru its key…
Javascript example:
myhash = {"name":"John", "occupation":"programmer"};
Debug.Log( myhash["name"] ); //displays "John"
sebako
5
Iam using both js and C#, but thank you all, exactly what I need 
rgds
zemog