The below nested dictionary practice is found in the in UIpath Academy Data Manipualtion practices.
Name_CityWeight_Dict =New Dictionary(Of String, Dictionary(Of String, Double)) From {
{“John C”, New Dictionary( Of String, Double) From {{“Madrid”,2.1},{“Paris”,1.1}} },
{“Sarah C”, New Dictionary( Of String, Double) From {{“New York”,2.1},{“Paris”,3.3},{“Berlin”, 0.8}} },
{“Kyle R”, New Dictionary( Of String, Double) From {{“San Francisco”,2.8},{“New York”,1.1}} },
{“Johnny B”, New Dictionary( Of String, Double) From {{“New York”,2.1},{“Paris”,3.3}, {“Cairo”,1.3}, {“Chicago”,1.9}} }
}
Now, to dispaly the dictionary as such,
For each PersonName in Name_CityWeight_Dict
WriteLine (PersonName.key) //gives the names as John C,Sarah C
For each city in PersonName.Value
WriteLine (" DICTIONARY ( " + PersonName.Key + "): is " + " (CITY NAME : " + City.Key.ToString + " , WEIGHT: " + City.Value.ToString + " )"
OUTPUT:
PERSON NAME : John C
DICTIONARY ( John C): is (CITY NAME : Madrid , WEIGHT: 2.1 )
DICTIONARY ( John C): is (CITY NAME : Paris , WEIGHT: 1.1 )
PERSON NAME : Sarah C
DICTIONARY ( Sarah C): is (CITY NAME : New York , WEIGHT: 2.1 )
DICTIONARY ( Sarah C): is (CITY NAME : Paris , WEIGHT: 3.3 )
DICTIONARY ( Sarah C): is (CITY NAME : Berlin , WEIGHT: 0.8 )
and it goes on .
My question here is ;
How to get the (Cityname,weight) ie.“Madrid”,2.1, “Paris”,1.1 without using iteration of another for each?
is there something like , WriteLine (PersonName.Value.Tokeyvaue()) ??what is the use of Tokeyvaue()?