Featured

    Featured Posts

    Social Icons

Loading...
infolinks

How to Run C# programs in Visual Studio

You can test your program a number of ways. First, though, it has to be built. This is when everything is checked to see if there are any errors. Try this:
  • From the View menu at the top of Visual Studio, click Output. You'll see a window appear at the bottom. (In VS 2010, if you can't see an Output option, click the Tools menu. From the Tools menu, select Settings > Expert Settings. The Output menu item should then appear on the View menu.)
  • From the Build menu at the top of Visual Studio, click Build Solution
  • You should see the following report:
The Output window in C# NET
The final line is this:
Build: 1 succeeded or up-to-date, 0 failed, 0 skipped
That's telling you that everything is OK.
Now try this:
  • Delete the semicolon from the end of your line of code
  • Click Build > Build Solution again
  • Examine the output window (version 2012 will just show and error and won't build)
This time, you should see these two lines at the end of the report:
Compile complete -- 1 errors, 0 warnings
Build: 0 succeeded or up-to-date, 1 failed, 0 skipped
So that it couldn't build your solution because there was 1 error.
Put the semicolon back at the end of the line. Now click Debug from the menu at the top of Visual Studio. From the Debug menu, select Start Debugging.
You should see a black DOS window appear and then disappear. Your program has run successfully!
To actually see your line of text, click Debug > Start Without Debugging. You should now see this:
Your C# Programme
And that's the output! Now have a look at the Solution Explorer on the right. Because the project has been built, you'll see more files under Debug:
The Debug item in the Solution Explorer
However, in Visual Studio 2010 you'll see a Release folder. Expand this:
The build files in C# 2010
We now have a ConsoleApp1.exe. The exe file is an executable program, and it appears in the bin/debug folder. Switch back to Windows Explorer, if you still have it open. You'll see the exe file there. (In the Release folder in visual studio 2010, but in the Debug folder in earlier versions):
The files in the bin/debug folder
If you want to create a desktop shortcut to this exe file. When you double click the desktop shortcut, the program will run.
author

This post was written by: Author Name

Your description comes here!

Get Free Email Updates to your Inbox!

Post a Comment

Rama Krishna

About Us

Powered by Blogger.
© Copyright aspdotnet-rk
Back To Top