Saturday, January 1, 2011

Hello World compared in C# and IronPython

A small Hello World app in C#

using System;
class Hello
{
private string _msg;
public Hello()
{
_msg = "Hello World";
}
public Hello(string msg)
{
_msg = msg;
}
public void SayHello()
{
Console.WriteLine(
_msg);
}
public static void Main()
{
Hello app = new Hello();
app.SayHello();
}
}


Equivalent in IronPython

class Hello(object):
    def __init__(self, msg='hello world'):
        self.msg = msg

        def SayHello(self):
           print self.msg

app = Hello ()
app.SayHello()