using System;
class MainClass {
public static void Main() {
string name;
Console.Write("Hello World: ");
name = Console.ReadLine();
if (name != null && name == "Test") {
Console.WriteLine("Test input.");
} else {
Console.WriteLine("Test not input.");
}
}
}
Hi, above is my simple C# code. I'm new to C#, although I am not new to programming as a whole. When I try this code (which I know has redundancy in the if statement, that's not the point) it prints garbage.
The code works normally, it just starts off like this:
Hello World: [6n[H[J[6n
I have no clue why it's adding [6n[H[J[6n. I tried looking it up, but I'm really at a loss. This code was working a few days ago, so maybe it's a compiler issue.
If anyone could help out, that would be much appreciated.
those are ansi console control codes. in ansi, [6n is "query cursor position", [h is "home" and [j is "erase down" http://www.termsys.demon.co.uk/vtansi.htm
To me, it looks like you were possibly pressing keys like home/delete/etc, and whatever console app you are running in is displaying them instead of interpreting them.
what kind of console are you running it in? were you pressing other keys while it is waiting?