How to loop a Console.ReadLine?

后端 未结 5 2041
醉酒成梦
醉酒成梦 2021-01-06 13:31

I cannot figure out how to read user-input in a loop (with Console.ReadLine). I\'m trying to create a note that lets me store what ever the user inputs, and exi

5条回答
  •  忘掉有多难
    2021-01-06 14:07

    To loop Console.ReadLine() you can use this

        `List al = new List(); //list to store string values
        while(true)
        {
            string f = Console.ReadLine();
            if(f == null)         //check if string is null or not
            {
                break;
            }
            else
                al.Add(f);        //add strings to list
        }`
    

提交回复
热议问题