Try to search your question here, if you can't find : Ask Any Question Now ?

Dictionary Issues

HomeCategory: stackoverflowDictionary Issues
Avatarrupesh asked 4 months ago

I am supposed to be making a dictionary of lists in order to show the scores of different peoples test, the final outcome is supposed to look like this: enter image description here

Currently my code looks like this, the issue I am having is that the numbers are printing 3 times, not once like shown. HELP PLEASE!

    static void Main(string[] args)
    {

        Random myRandomGenerator = new Random();

        Dictionary<string, List<int>> table = new Dictionary<string, List<int>>();

        table["Meuleveld, McKenzie"] = new List<int>(){ myRandomGenerator.Next(60, 100), myRandomGenerator.Next(60,100), myRandomGenerator.Next(60,100)};
        table["McGuire, Matthew"] = new List<int>(){ myRandomGenerator.Next(60, 100), myRandomGenerator.Next(60, 100), myRandomGenerator.Next(60, 100) };
        table["Anderton, Paitlyn"] = new List<int>(){ myRandomGenerator.Next(60, 100), myRandomGenerator.Next(60, 100), myRandomGenerator.Next(60, 100) };
        table["Moore, Jeni"] = new List<int>(){ myRandomGenerator.Next(60, 100), myRandomGenerator.Next(60, 100), myRandomGenerator.Next(60, 100) };

        foreach (string name in table.Keys)
        {
            List<int> value = table[name];

            foreach (int valueList in value)
            {

                    Console.WriteLine($"{name} exam scores: {valueList}, {valueList}, {valueList}");

                Console.ReadKey();
            }
        }
    }
1 Answers
Best Answer
AvatarArben answered 4 months ago
Your Answer

9 + 0 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com