Why isn't my console showing up? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 2

Why isn't my console showing up?

Whenever I try to run a code for C# in Visual Studio, for, let's say a text message should appear, it only flashes the console for about a second before closing down again. How do I prevent this?

5th Jul 2018, 10:12 PM
Captain Fagget
Captain Fagget - avatar
5 ответов
+ 4
Try adding Console.ReadKey() at the end of your main method. IIRC, Visual Studio doesn't keep the window open unless it blocks. So, what's really happening is that the message is printing, but the program ends as soon as it is printed, so VS closes the console.
5th Jul 2018, 10:17 PM
LunarCoffee
LunarCoffee - avatar
+ 5
[No Name] Seeing your problem was resolved already it would be great if you can mark the answer that you find useful to encourage the community to help each other out. 😉
6th Jul 2018, 4:41 AM
Zephyr Koo
Zephyr Koo - avatar
+ 3
Btw I just got into coding, so please don't get rough on me >_<
5th Jul 2018, 10:14 PM
Captain Fagget
Captain Fagget - avatar
+ 2
Oh wow, thanks for replying so fast! I tried putting it in and it works like a charm, thanks for the help :)
5th Jul 2018, 10:25 PM
Captain Fagget
Captain Fagget - avatar
0
It works, but I'm used to IntelliJ IDE where the console permanently lives in the bottom portion of the screen, so I can see it all the time. Whereas the Console.ReadKey() just keeps it open as a separate window. Any advice?
26th Dec 2019, 3:23 AM
Shtisim Lukshen
Shtisim Lukshen - avatar