(Char)13
is a carriage return, while (Char)10
is a line feed. As others have said, this means that (Char)13 will return to the beginning of the line you are on, so that by the time you have written the (shorter) line 2, it will be written over the first section of the string - thus the remaining "E".
If you try it with a shorter second string, you can see this happening:
string text = "THIS IS LINE ONE " + (Char)13 +"test";
Console.WriteLine(text);
gives output:
"test IS LINE ONE"
Therefore, to solve your problem, the correct code will be:
string text = "THIS IS LINE ONE " + (Char)10 +"test";
Console.WriteLine(text);
which outputs:
THIS IS LINE ONE
this is line 2
Edit:
Originally, since you said your printer requires it to be a (Char)13, I suggested trying both (Char)10 + (Char)13
(or vice versa) to achieve a similar effect. However, thanks to Peter M's exceedingly helpful comments, it appears the brand of printer you are using does in fact require just a (Char)10
- according to the manual, (Char)10
will produce a line feed and a carriage return, which is what you require.
Console.WriteLine
, and not a problem with the actual characters, it is a "problem" with the standard console behavior. The printer may or may not behave the same way, the behavior of the console has no impact on this. – Banebrudge