+ 1
how to use string and Console.ReadLine to enter multiple inputs?
3 Réponses
+ 1
When i make advanced consoles, i usually make a method that returns a string, like:
// The 'msg' parameter is not needed, it only allows you to quickly make the difference of:
//hi this is input
// And:
//> hi this is input if i typed "> " in the parameter.
private static string GetInput(string msg = "")
{
    Console.Write(msg);
    return Console.ReadLine();
}
And i call it in the main like:
public static void Main(string[] args)
{
    string cmd = GetInput("> ");
    Console.WriteLine(cmd);
    cmd = GetInput();
    Console.WriteLine(cmd);
}
Good luck!
0
A suggestion would be to maybe use a for loop that includes a string variable that takes in Console.ReadLine() depending on the condition number. 
0
Example of my suggestion below:
class Program
	{
		static void Main(string[] args)
		{
			for(int i=1; i<6; i++)
			{
				Console.Write(i + " " + "Write a name");
				string strVar = Console.ReadLine();
Console.WriteLine(strVar);
			}
		}
	}



