Cal*_*lat 10 c# cmd path environment-variables csc
我是C#的新手,我正在尝试使用cmd来编译一个名为的基本hello world文件test.cs.它包含以下内容:
// Similar to #include<foo.h> in C++, includes system namespaces in a program
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// A name space declaration, a class is a group of namespaces
namespace Program1
{
class Hello // my class here, classes can contain multiple functions called methods which define it's behavior
{
static void Main(string[] args) // main method, just like in C/C++ it's the starting point for execution cycle
{
Console.WriteLine("Hello World");
Console.ReadKey(); // similar to _getch() in C++ waits for user to input something before closing
}
}
}
/*
* Other notes, .cs is a c# file extension
* cs files can be built via terminal by using csc foo.cs to generate foo.exe run it with foo
*/
Run Code Online (Sandbox Code Playgroud)
Am_*_*ful 21
找到csc.exe的路径并将其添加到您的PATH环境变量中.
在我的例子中,64位C#编译器的路径是C:\Windows\Microsoft.NET\Framework64\v4.0.30319.
同样,您可以C:\Windows\Microsoft.NET\Framework在不同的.NET框架版本目录中查找32位C#编译器
所有版本都会有csc.exe,如v2.0.XXXXX和v3.5.根据您的要求,在Framework64/Framework目录中选择具有最高版本的版本.
复制csc.exe的路径并将其添加到PATH系统环境变量.
退出cmd,然后再次启动并运行该程序.那很有用.
| 归档时间: |
|
| 查看次数: |
22726 次 |
| 最近记录: |