martes, septiembre 09, 2008

C# and more dynamic features (C# 4.0?)

static void Main(string[] args)
{
    dynamic
    {
        object myDynamicObject = GetDynamicObject();
        myDynamicObject.SomeMethod();         // call a method   
        myDynamicObject.someString = "value"; // Set a field
        myDynamicObject[0] = 25;              // Access an indexer
    }
}

How cool is it? I don’t know, probably will be something dangerous if not used with care, C# depend a lot of compile time checking.

To see more about this see Charlie Calvert’s Blog

No hay comentarios.: