Issue with compiler error in dictionary exercise - figured out

Feedback about the Data Manipulation Academy course.
Please type your feedback below.

While writing this course and doing the exercise I figured out the solution which I could not find previously on the forum.

there is a section in the course where it asks you to iterate over a dictionary then using an if statement do one of two print out options. the issue with this however if the compiler refused to acknowledge the dictionary as being set correctly. It woul dgive compiler errors like below

Main.xaml: Compiler error(s) encountered processing expression “String.Format(”{0} with {1} victories: “, Winner.Key, Winner.Value)”.
‘Key’ is not a member of ‘System.Collections.Generic.Dictionary(Of String, Integer)’.
‘Value’ is not a member of ‘System.Collections.Generic.Dictionary(Of String, Integer)’.

indicating that there is no such thing as a key or value component of dictionary, after much combing I noticed this in the actual official solution

this detail of the forEach statement does not use the generic dictionary to iterate over its items it uses a generic.KeyValue.Pair. the variable created is of type dictionary but this one section if not set does not allow the normal solution written as is to work.

putting it here to hope it helps anyone else in the future, just update the typeArgument for the for each and it solves it.

if someone could provide context or guidance on WHY it does it that way and WHY the compiler says Key and Value do not exist as part of type dictionary that would be a good learning lesson, maybe update the solution note to include a tidbit indicating that when you create that for each loop it should be of the right type to stop this headache appearing.

replying to mark as solved (Assuming I can do this). Solution is in question description

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.