lastunicorn / ConsoleTools

A set of tools and "controls" for the .net Console.
GNU General Public License v3.0
73 stars 5 forks source link

TextMenu - clear console's buffer before read #35

Open lastunicorn opened 6 years ago

lastunicorn commented 6 years ago

Before reading the user's input, clear the console buffer.

If it is not cleared, the user may type keys before the menu is displayed. The menu may execute some item that the user didn't intended.

This code might help:

while (Console.KeyAvailable)
    Console.ReadKey(true);