Answer the question
In order to leave comments, you need to log in
How to enter a user value into an array?
Hello! I would like to make the user use Console.ReadLine() to enter the value into the array .
Please explain in the if condition .
Answer the question
In order to leave comments, you need to log in
I need to have the user in the console using Console.ReadLine(); he entered the value into the array cell.
var arraySize = int.Parse(Console.ReadLine());
var array = new int[arraySize];
for(var i = 0; i <= array.Length; i++) {
array[i] = int.Parse(Console.ReadLine());
}
var list = new List<int>();
// Заполняем список числами, которые вводит пользователь, пока пользователь не введёт q
var input = Console.ReadLine();
while(input != "q") {
list.Add(int.Parse(input));
input = Console.ReadLine();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question