C# Dynamic Lookup – a suggestion.

Paul Stovell passed around a link to this blog post by Charlie Calvert and Mads Torgersen about the dynamic lookup feature in a future version of C#. Personally I like the feature and I can see myself using it in a few specific circumstances.

Reading through it, I’ve got two suggestions. We need to ability to use a string variable or literal to name the member that we are interacting with. This would be incredibly helpful for things like dynamic sorting scenarios in web applications.

The second suggestion is turning the dynamic lookup into a kind of duck typing facility where-by you can continue to use the object outside the dynamic scope provided you only access the members that you had accessed inside the dynamic scope – although I am not sure if that is terribly useful, just a thought.


One thought on “C# Dynamic Lookup – a suggestion.

  1. Noman Ali

    C# 4.0 introduces a new type dynamic. A variable define as dynamic will always be late bind i.e. all the calls to properties or methods will be resolved at runtime. An exception will be raised at run time if the object doesn’t supports the property or method.

    The syntax for using dynamic type is

    dynamic d1 = GetSomeDynamicObject();
    d.Property = 1;


    Easy COM Interop scenarios
    Support for dynamic languages
    More support for reflection

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s