2

Hi im starting to learn c# just now with visual studio 2012 and windows 8, and the tutorial has given some .cs files and not explained how to run them. It is all command line stuff in this tutorial. This stack overflow answer gave the most easy-sounding way of doing it (in response to a similar question by someone else).

If you already installed Visual Studio, just: Click Start, point to All Programs, point to Microsoft Visual Studio, point to Visual Studio Tools, and then click Visual Studio Command Prompt and there you have your command line box where you compile as follows:

csc PathToYourCsSource

I cannot find visual studio tools. I typed it into the search in windows 8. Thanks

4 Answers 4

6

It is easier to: Run Visual studio -> Make a new C# console project.

This makes a project with a simple Program.cs file. You can just copy/paste in that, and run the project my clicking F5.

1
  • Is there just a "compile and run" button anywhere that you can use that is similar to pushing F5 in python IDLE? Its difficult to understand all of the different set ups they have for APIs, webpages, databases, etc. if they change the button each time. I was trying to run a '.cs' file I made for a hello world program in C# and I couldn't run it because it wanted to "append to another process"... Seems like "compile and run" button similar to IDLE or Eclipse would be useful to always be available.
    – chase
    May 2, 2014 at 23:29
1

"Visual Studio Tools" is the name of the folder in the All Programs list, not the name of an item you can find by searching. You can search for "Developer Command Prompt for VS2012" (or some portion of that) instead.

I'd recommend that instead, you work with your .cs file as part of a project in Visual Studio. It's easy to create and run a Console Application from the IDE.

1
  • Thank you, i just found the command prompt for VS with what you told me, however on first attempt it could not find the file, when it seems i typed the correct full path. For now I think i will just create a new console application and copy and paste the code to run it as it did work and is not much effort. Aug 4, 2013 at 0:00
0

You can also use tools like Linqpad to run snippets of code so you don't have to use the bloat of an entire Visual Studio solution/project.

0

1.

in visual studio directory go to Common7>Tools>Shortcuts>Developer Command Prompt for VS2013 run this ,type csc programName.csc for compiling and programName for run

Make sure to change the directory of console to your program path

2.

In visual studio create new C# console application and write there ,for run go to menu debug>Start Debugging

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.