let's say I want to make a program that takes as input: {personName} {food1} {food2} ... {foodN}. Then they should be stored in a Dictionary - The Key should be the {personName}, and the Value should be a list that stores all the food[n], that is in the input. Then i want to print them like this {personName} -> {food1}, {food2}, {food3} ... {foodN}.
using System;
using System.Collections.Generic;
using System.Linq;
namespace stack1
{
class Program
{
static void Main(string[] args)
{
string input = Console.ReadLine(); // George, Pizza, Burger
Dictionary<string, List<string>> peopleFood = new Dictionary<string, List<string>>();
while (input != "stop")
{
List<string> inputs = input.Split(" ").ToList(); // George, Pizza, Burger
peopleFood.Add(inputs[0], inputs[1], inputs[2]); // George, Pizza, Burger
input = Console.ReadLine(); //stop
}
Console.WriteLine(); // George -> Pizza, Burger
}
}
}
The .Add function is not working with 3 elements, and I don't know what else to use. The same goes for the printing process - I don't know how to print the output i want .