is there way in c# close console application when user inputs letter - without using command 'press key continue...' .
i.e. if write message 'do want quit (y/n) ?' , user inputs letter y.
namespace example { class program { static void main(string[] args) { console.write("do want quit game? (y, n): "); char yn = console.readline()[0]; if (yn == 'y' || yn == 'y') { } else if (yn == 'n' || yn == 'n') { console.writeline("continue game..."); } } } }
use environment.exit(0) inside y condition
class program { static void main(string[] args) { console.write("do want quit game? (y, n): "); char yn = console.readline()[0]; if (yn == 'y' || yn == 'y') { environment.exit(0); } else if (yn == 'n' || yn == 'n') { console.writeline("continue game..."); } } } }
Comments
Post a Comment