Yet another Hello World

Posted by Jb Evain Wed, 30 Jan 2008 20:51:00 GMT

Statue

using System;
using System.Linq.Expressions;

class HelloWorldOfTrees {

    static void Main ()
    {
        var param = Expression.Parameter (typeof (string), "p");

        var cwl = Expression.Lambda<Action<string>> (
            Expression.Call (
                typeof (Console).GetMethod (
                    "WriteLine", new [] { typeof (string) }),
                param), param).Compile ();

        cwl ("Hello World !");
    }
}
[mono] /tmp @ gmcs test.cs 
[mono] /tmp @ mono test.exe 
Hello World !

Well heh, you can’t do really much more than that, but at least, that is working (sort of).

Trackbacks

Use the following link to trackback from your own site:
http://evain.net/blog/articles/trackback/470

Comments

Leave a response

Comments