简体   繁体   English

使用Mono的代码运行器编译C#代码

[英]Compile C# code with code runner with Mono

I am trying to compile this simple C# code on OS X: 我正在尝试在OS X上编译以下简单的C#代码:

using System;

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine("hello");
    }
}

This was the code runner template. 这是代码运行器模板。

I have installed Mono, and the run command is mono $compiler. 我已经安装了Mono,运行命令是mono $ compiler。 I first tried using the default Compile.sh file, and it didn't work, so I've found on the web a guide that says to write a shell script like this one: 我首先尝试使用默认的Compile.sh文件,但该文件无法正常工作,因此我在网上找到了一个指南,上面写着这样的shell脚本:

enc[4]="UTF8"           # UTF-8
enc[10]="UTF16"         # UTF-16
enc[5]="ISO8859-1"      # ISO Latin 1
enc[9]="ISO8859-2"      # ISO Latin 2
enc[30]="MacRoman"      # Mac OS Roman
enc[12]="CP1252"        # Windows Latin 1
enc[3]="EUCJIS"         # Japanese (EUC)
enc[8]="SJIS"           # Japanese (Shift JIS)
enc[1]="ASCII"          # ASCII
file=$1
file=${file/\.cs/\.exe}


mcs "$1"
echo "$file"
exit 0

So I've changed it (backup-ed the old one), but I still get this error on the console: 所以我已经更改了它(备份了旧版本),但是在控制台上仍然出现此错误:

bash: Run Command: No such file or directory bash:运行命令:没有这样的文件或目录

除非您特别需要从命令行进行编译,否则我强烈建议您使用MonoDevelop,而不是尝试找出适当的命令行参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM