Skip to content

Instantly share code, notes, and snippets.

@abdulateef
Last active July 2, 2017 06:58
Show Gist options
  • Save abdulateef/38223ec26060937bc30d120ed1e97444 to your computer and use it in GitHub Desktop.
Save abdulateef/38223ec26060937bc30d120ed1e97444 to your computer and use it in GitHub Desktop.
how to terminate a console program on a button click
Console.WriteLine("Oop!! an error has occured");
Console.WriteLine("Press Enter to exit the program..." + "OR" + "Press Back Space to see the error");
ConsoleKeyInfo keyinfor = Console.ReadKey(true);
if(keyinfor.Key == ConsoleKey.Enter)
{
System.Environment.Exit(0);
}
else if(keyinfor.Key == ConsoleKey.Backspace)
{
Console.WriteLine(ex.Message);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment