If I have six names and a number related to each name(six inputs) how can I get as an output the name who has the greatest nr? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

If I have six names and a number related to each name(six inputs) how can I get as an output the name who has the greatest nr?

nested loops

24th Jan 2017, 3:51 PM
patrik
2 Answers
0
Assuming a dictionary of names as keys and numbers as values: Dictionary<string, int> dictionary = new Dictionary<string, int>(); ....add all the values to dictionary string maxName = dictionary.MaxBy(kvp => kvp.Value).Key;
24th Jan 2017, 5:19 PM
Josh Davidson
Josh Davidson - avatar
0
thank you
24th Jan 2017, 8:49 PM
patrik