Hello Friends,
How make Dictionary have Index?
example :
public static Dictionary<string, List> parentChildrenGroup = new Dictionary<string, List>();
I want :
for(int i=0; i<9; i++){
parentChildrenGroup [ i ] <<< like this have Index
}
Help me
You can’t. You can iterate over the dictionary.Keys or dictionary.Values by index, if you need to. You could also have a List of Dictionaries.
As it’s a dictionary of lists of strings you can iterate over each list in the dictionary with something like
for(int n = 0; n < parentChildrenGroup["key"].Count; n++)
{
Debug.Log(parentChildrenGroup["key"][n]);
}
substituting “key” with the actual dictionary key of interest.