Posteado por: felixcriv | junio 18, 2009

Getting started with C# in Mac OS X

Days ago, I wrote the reasons why C# is being so popular. Mono project is one of the reasons of it.

So, I’ve decided to try by myself to get an environment in order to work with C# using my mac. In this case I’ve downloaded the .net framework for Mac OS X (at the Mono Project website), and I’ve looked for the C#’s compiler documentation in order to generate the classic “Hello World” application for Mac OS X (10.5.7).

Is pretty easy, just download the mono-project package and double click in the package, follow the installer instructions, after that you can open any text editor and paste this code (I use TextMate):

using System;
using System.Windows.Forms;
public class test {
public static void Main(){
MessageBox.Show(“Hello World”);
}
}

using System;

using System.Windows.Forms;

public class test {

public static void Main(){

MessageBox.Show(“Hello World”);

}

}

and save it as “hello.cs” inside a new Folder “Hello” in your path ~/username/.

12

Then, open a terminal (/Applications/Utilities/Terminal) and type this:

mcs hello.cs /r:System.Windows.Forms.dll /out:hello.exe

The command above generates a (dot) .exe file (windows executable) that you can run over any windows platform with .net framework 3.0 installed

Now, let’s go to make a Mac OS X application with:

macpack -n:hello -a:hello.exe -o:Hello

This will generate an app called “hello.app“, inside the folder “Hello
13Executing such file,
14Finally, We got a C# application running over Mac OS X thanks to mono-project, so let’s program some apps with C#.

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s

Categorías

A %d blogueros les gusta esto: