Just sharing some of my inconsequential lunch conversations with you... RSS  

Sunday, January 27, 2008

Dynamic Lookup

For much as I like the world to be a statically typed and known at compile time, their are cases where late-binding and duck-typing comes handy.

C# couldn't handle runtime name resolution easily, but it will in a (near?) future. Here's how, according to Charlie Calvert:

static void Main(string[] args)
object myDynamicObject = GetDynamicObject();

myDynamicObject.SomeMethod(); // call a method
myDynamicObject.someString = "value"; // Set a field
myDynamicObject[0] = 25; // Access an indexer

Nice and simple. Man, I just love C# plasticity....

No comments:

Development Catharsis :: Copyright 2006 Mário Romano