My code doesn't execute on VS 2012 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

My code doesn't execute on VS 2012

The very same code doesn't execute unless I end my code with Console.Read(); why it that?

26th Feb 2017, 8:41 AM
Thabo
Thabo - avatar
4 Answers
+ 1
Yes, the Console application on c# at the end you need to put Console.ReadLine() as like we put getch() in C programming ^_^ . but it for our UI purpose , if you don't write it, till the application run but we can't able to see the output console , that's why we put the readKey()
26th Feb 2017, 9:29 AM
Arshit patel
Arshit patel - avatar
0
the code is execute , but the process is fast so , you can't able to see that on terminal. As you write console.read() it wait till you press Enter or Console.readKey() it wait till any key press and then after the terminal goes.
26th Feb 2017, 9:19 AM
Arshit patel
Arshit patel - avatar
0
Thanks Ap Star, so every code must end with Console.ReadLine(); if it has to be executed by pressing Enter?
26th Feb 2017, 9:23 AM
Thabo
Thabo - avatar
0
The end code should be Console.ReadLine (); OR Console.ReadKey ();
27th Feb 2017, 5:30 PM
Kashif Younus
Kashif Younus - avatar