I've got a Console.ReadLine()
inside a finite for loop
that never ends reading.
I am using VS Code on Linux Mint. I execute by pressing F5.
using System;
class Person
{
public string Name { get; set;}
public override string ToString()
{
return "My name is " + Name;
}
}
class Program
{
static void Main(string[] args)
{
int n = 3;
Person[] p = new Person[n];
for (int i = 0; i < n; i++)
{
p[i] = new Person()
{
Name = Console.ReadLine()
};
Console.WriteLine("I just read " + p[i]);
}
for (int i = 0; i < n; i++)
{
Console.WriteLine(p[i].ToString());
}
}
}
I expected to input three names and then output them.
I input by typing a name and then pressing Enter.
The issue is that I can keep inputting forever and that Console.WriteLine("I just read " + p[i]);
never gets executed. This happens in the Debug Console.