I would like to get the user enters two different values using only ONE statement of Console.ReadLine()
.
More specifically, instead of using two different variables declarations with two different ReadLine()
method - I want to let the user enters two variables at the same time using one ReadLine()
method for further processing.
Asked
Active
Viewed 9,590 times
4
2 Answers
2
Console.WriteLine("Enter values separated by space");
string input = Console.ReadLine();
string[] inputs = input.Split(' ');
foreach (string inp in inputs)
{
Console.WriteLine(inp);
}

Bala R
- 107,317
- 23
- 199
- 210