Creating Your First Mono Program

This section shows you how to create a short program in C# that will do a more complete test of the mono environment. Open an editor on the Linux machine: For this example, we will use gedit; however, any editor will do. (If you prefer, type command_line_applications, run vi, or emacs at the command prompt). Enter the following code:

using System;
class Hello
{
  public static void Main(String[] args) {
    Console.WriteLine("Mono is working...");
    for (int i = 0; i < args.Length; i++)
      Console.WriteLine("{0}. Hello {1}!", i, args[i]);
  }
}
  • Find the Code on the CD: \Code\Chapter 08\Ex01.

Save the file as hello.cs, and open a terminal window. Navigate to the location of hello.cs and execute

$ mcs hello.cs

If all is well, ...

Get Delphi for .NET Developer’s Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.