I want to create a function which will return the matrix, but I have a problem with limit the time of put the data to console.
public static List<List<int>> CreateMatrix()
{
List<List<int>> matrix = new List<List<int>>();
List<int> row = new List<int>();
do
{
row = Array.ConvertAll<string, int>(Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries), int.Parse).OfType<int>().ToList();
matrix.Add(row);
} while (matrix[0].Count == row.Count);
return matrix;
}
I want to create a loop which will accept the row of numbers, but when nothing is put inside the row at least five seconds for example, then the loop should be break