mingchaoyan
mingchaoyan

Reputation: 8586

How to compile single c# file on mac console using mono?

I want to compile a simple "hello world" on mac console. I have made dmcs symbolic on /usr/local/bin/.

using System; 

class Hello 
{ 
      static void Main(){ 
     Console.WriteLine("Hello,World"); 
    } 
}

But after typing

dmcs Hello.cs

I get Hello.exe

.exe file seems a Windows file.

So, How to compile single c# file on mac console using mono?

Upvotes: 1

Views: 2716

Answers (1)

Ron Beyer
Ron Beyer

Reputation: 11273

JamesSugrue is right in your comment, you need to run the project using the mono framework using the described command line.

mono Hello.exe

The mono compiler creates files with extensions just like csc would on Windows. The difference is that on Mac and Linux the extension really is a suggestion about what is inside, rather than a rule like it is on Windows.

Upvotes: 3

Related Questions