命令行编译C#报错

今天刚开始学C#,Visual Studio倒是可以编译了,好家伙。命令行却不能编译。
哦,对了,如果一开始报这个错

‘csc’ 不是内部或外部命令,也不是可运行的程序或批处理文件。

说明你没配置环境变量。。。。。。

下面这个错,说明你环境变量配错了。。。。。

This compiler is provided as part of the Microsoft ® .NET Framework, but only supports language versions up to C# 5, which is no longer the latest version. For compilers that support newer versions of the C# programming language, see http://go.microsoft

于是乎,咋个解决呢,打开环境变量,就是在搜索框里直接搜索环境变量,或者通过控制面板打开它。
编辑系统环境变量,双击Path,然后新增。
把你安装vs的那个bin下的Ros地址给它po进去,我的是这个

D:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Roslyn

1
然后一顿确定操作,搞定,
然后再csc helloworld.cs
然后再 helloworld
然后恭喜你,成功了!

猜你喜欢

转载自blog.csdn.net/qq_43738932/article/details/126146969