I'm currently experimenting with Stacks using C#. I've created this little testing program to push, pop and view the stack:
Stack st = new Stack();
Console.WriteLine("Add item to Stack");
int inp = Convert.ToInt32(Console.ReadLine());
st.Push(inp);
ty:
Console.WriteLine("");
Console.WriteLine("A to Add");
Console.WriteLine("D to Pop");
Console.WriteLine("V to View");
char act = Console.ReadKey().KeyChar;
switch (act)
{
case 'A':
Add(st);
break;
case 'D':
Remove(st);
break;
case 'V':
View(st);
break;
default:
Console.WriteLine("Not an valid option");
break;
}
goto ty;
However, when I try to enter a character for the decision part, this instantly leads it being repeated on the same line like this:
The question is, why does this occur; am I using Console.WriteLine incorrectly?