C# 运行 .cs 文件 - Visual Studio 2012
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18038389/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Run a .cs file - visual studio 2012
提问by user2602079
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).
嗨,我刚刚开始使用 Visual Studio 2012 和 Windows 8 学习 c#,教程给出了一些 .cs 文件,但没有解释如何运行它们。这是本教程中的所有命令行内容。这个堆栈溢出答案给出了最简单的方法(回应其他人的类似问题)。
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:
如果您已经安装了 Visual Studio,只需:单击开始,指向所有程序,指向 Microsoft Visual Studio,指向 Visual Studio 工具,然后单击 Visual Studio 命令提示符,然后您就有了命令行框,您可以在其中进行如下编译:
csc PathToYourCsSource
csc PathToYourCsSource
I cannot find visual studio tools. I typed it into the search in windows 8. Thanks
我找不到 Visual Studio 工具。我在 Windows 8 的搜索中输入了它。谢谢
采纳答案by Smarties89
It is easier to: Run Visual studio -> Make a new C# console project.
更容易:运行 Visual Studio -> 创建一个新的 C# 控制台项目。
This makes a project with a simple Program.csfile. You can just copy/paste in that, and run the project my clicking F5.
这使项目具有简单的Program.cs文件。您可以直接复制/粘贴其中,然后单击 F5 运行该项目。
回答by Tim S.
"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.
“Visual Studio Tools”是“所有程序”列表中文件夹的名称,而不是您可以通过搜索找到的项目的名称。您可以搜索“VS2012 的开发人员命令提示符”(或其中的某些部分)。
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.
相反,我建议您将 .cs 文件作为 Visual Studio 中项目的一部分进行处理。从 IDE 创建和运行控制台应用程序很容易。
回答by Cubicle.Jockey
You can also use tools like Linqpadto run snippets of code so you don't have to use the bloat of an entire Visual Studio solution/project.
您还可以使用Linqpad 之类的工具来运行代码片段,这样您就不必使用整个 Visual Studio 解决方案/项目的膨胀。
回答by Suyash Kumar Singh
1.
1.
in visual studio directorygo to Common7>Tools>Shortcuts>Developer Command Prompt for VS2013run this ,type csc programName.csc
for compiling
and programName
for run
在visual studio目录中转到Common7>Tools>Shortcuts>Developer Command Prompt for VS2013run this,输入csc programName.csc
编译和programName
运行
Make sure to change the directory of console to your program path
确保将控制台目录更改为您的程序路径
2.
2.
In visual studiocreate new C# console applicationand write there ,for run go to menu debug>Start Debugging
在Visual Studio 中创建新的C# 控制台应用程序并在那里编写,运行时转到菜单debug>Start Debugging