Skip to content

How do I view the "output" of my code in Visual Studio permanently like with .NET?

Complete noob here, sorry if this is stupid, I did google first but couldn't find what I was looking for, probably because I can't explain it well enough so bear with me as I try to do that now:

​

  • I'm currently following the "Hello World" intro to C# course on microsoft.learn
  • on the .Net editor I type in my code, press run, and in the output window it displays the code I just put down
  • When I tried to do the same thing in visual studio, the output showed up in a tiny window for a split second then disappeared, as the code became more "complicated" the window didn't show up at all even though it said there were no errors
  • Mac monterey 12.6.1
    Appreciate any help, thanks.
2 points7 comments
Open on Reddit
About this post
Posted
Archived
Score
2 · 67% up
Kind
Text
ID
14rw654

Author

16
posts
21
comments
1
media
View profile

8 comments

try adding Console.ReadLine() at the end

3 points

To add onto this, by adding Console.ReadLine(), the program waits for the user input, and keeps it running.

The application will exit when there's nothing else to "do".

2 points

The .Net editor sounds like it uses the .Net Framework, which can display things. The "hello world" programm on .Net tells the framework to display "hello world".

If you are using Visual Studio (alone), you don't automatically use any Framework to display anything. That is likely why something that worked in the .Net editor to display text doesn't work in VS.

That means the programm opens in a console, but has nothing to display, so it does everything it is supposed to do but closes right after. What the other comment said should tell your programm to display whats in the brackets and add a linebreak, which in turn prompts it to stay (as a console) and not instantly close.

If you are also using the .Net Framework in Visual Studio, it might just be that VS doesn't tell .Net to start properly. In any case, a look on the code would be helpful here.

0 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.