I have an unknown number of lines of input. I know that each line is an integer, and I need to make an array with all the lines, for example:
Input:
12
1
3
4
5
and I need to get it as an array: {12,1,3,4,5}
I have the below code, but I can't get all the lines, and I can't debug the code because I need to send it to test it.
List<int> input = new List<int>();
string line;
while ((line = Console.ReadLine()) != null) {
input.Add(int.Parse(Console.In.ReadLine()));
}
StockItem[] stock = new StockItem[input.Count];
for (int i = 0; i < stock.Length; i++) {
stock[i] = new StockItem(input.ElementAt(i));
}