Compile error with "+" operator and types 'Double'

I’m facing below two errors in a practice exercise:

In a Assign activity :
Error ERROR Validation Error Compiler error(s) encountered processing expression “Cities(City) + CitySent(City)”.
Operator ‘+’ is not defined for types ‘Double’ and ‘System.Collections.Generic.Dictionary(Of String, Double)’. Practice4_Dictionaries_WeightCalculation_START.xaml

Note: Cities is a varible of type Dictionary( od String, Double)

In a Invoke activity with Cities as TagetObject and CitySent.Item(City) as parameter:

Error ERROR Validation Error Compiler error(s) encountered processing expression “CitySent.Item(City)”.
Value of type ‘System.Collections.Generic.Dictionary(Of String, Double)’ cannot be converted to ‘Double’. Practice4_Dictionaries_WeightCalculation_START.xaml

I’ve compared with the solution and i’m seeing the same, but the errors remains.

what are you trying to do here? @ricard.gil

In the Assign activity, I want to add a double to the Cities <String, Double> Dictionary :
Cities(City) = Cities(City) + CityList(City),
where City is the item inside a For Each activity that iterate each city from another dictionary (of String, Dictionary(Of String, Double).
It exercise corresponds to the Practice 4 of “Dictionaries & Doubles” of Data Manipulation lesson.

From the error message, it seems like your CityList(City) is again a dictionary variable, which can not be directly converted to Decimal.
Can you please share below details-

  1. Data types of variables Cities and CityList
  2. Use Log message activity before the additional operation and display the value as,
    "Cities : " + Cities.GetType().ToString + " CityList : " + CityList.GetType().ToString

I’ve already resolved.
The problem was in the TypeArgument of fisrt For each activity, I don’t know why it was Dictionary<Dictionary, Double> instead of Dictionary<String, Double>, si then the additional operation is working.

Thanks a lot for your help!

1 Like

please advise what are the prerequisites to fully understand these type of examples.