Jan Schreuder on .Net

.Net code samples, experiences, observations

View my professional profile on LinkedIn

Recent Posts

Tags

News

  • Inappropriate comments will be deleted at my discretion.

    The information and code samples in this weblog is provided "AS IS" without warranty of any kind, either expressed or implied, including but not limited to the merchantability and/or fitness for a particular purpose.

Community

Email Notifications

Tool suppliers

Tools

General

Microsoft

Favorite blogs

Archives

Dynamic type support in C# aka Late Binding

VB6 and VB.Net developers know this feature: "Late Binding" and C# developers have often ridiculed that option. Buit it seems that the next version of Visual Studio will support a feature called "Dynamic type support". An article on this new feature can be found here, at Charlie Calvert's Community Blog. James Manning likes the idea but has some remarks about the suggested implementation. You can read about that here.

Currently, C# developers will need to use reflection to instantiate the object and discover methods and properties. The way the C# team are thinking about the implementation will make dynamic objects work something like this:

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
    }
}

If you've worked with reflection before, you immediately see how simple this will be. And the way it will be integrated into the CLR will allow other languages to use this as well.

Looks like another promising feature for C#!

Posted: Feb 21 2008, 01:41 PM by Jan Schreuder | with no comments
Filed under: ,
Leave a Comment

(required) 

(required) 

(optional)

(required)