Wieso verschwindet der erste Buchstabe im folge WriteLine(), wenn ich auf „Esc“ tippe? Und wie kann ich dieses verhindern?
code:
using System;
namespace ConsoleEscapApp
{
class Program
{
static void Main(string args)
{
bool b=false;
do
{
Console.WriteLine(„Hello World!“);
ConsoleKeyInfo x = Console.ReadKey();
Console.WriteLine(„“);
} while (b==false);
Hi @Tamara_Laura, nichts für ungut aber es gibt so Suchmaschinen zB ggle… und ohne die kommt man heutzutage nicht so gut zurecht, wie mit - grad im Programmiererleben. Selbst die gute Gemeinde hier ist in Vielem nicht so schnell und effektiv wie eine Suchmaschine: gleich der 1. Link zB erklärt dein Problem gut und die Lösung ist auch anbei!
Normal behavior, you’re printing the escape character to the console, so the following character will be a treated as a control character. You need to always hide Console.ReadKey and Console.Write the characters yourself (excluding the escape).
Anbei nochmal 2 Links zu C# IDEs / Codeeditoren zum ausprobieren (ohne install) - die eine mit dem Code drin ist zwar komfortabler aber da rennt der Code irgend wie nicht gut, bei der 2. ist alles gut: