Patrick Dwyer

Echo :: C#

in News, Comparative Programming, C# by patrick

This program is part of the Comparative Programming :: Echo set of examples.

On OS X there is no out-of-the-box support for C#, so we need to install a set of tools to compile and run C# programs. We’ll be using the Mono framework to work with C#. Installing Mono is straight forward on OS X; just download the Disk Image, and follow the instructions on screen.

Using the Mono framework we can write examples in C# on platforms other than Windows. The C# echo program looks strangely similar to the Java example. The library layouts are different between to two, but they largely share idioms and ideas. This example follows our tried and true method of printing out each argument followed by a space, finishing the program by printing a newline.

using System;
class echo {

static void Main(string[] args) {
foreach(string arg in args) {
Console.Write("{0} ", arg);


Program Source: echo.cs

Compiling the example

From the command line:

mcs echo.cs

Running the example

From the command line:

mono echo.exe Hello World