« Issue Dynamic LINQ Queries to SQL Databases with LINQPad | Main | Microsoft Releases Source Code for the .NET Framework »

27.09.07

Duck Typing in C#

I stumbled upon David Meyer’s Duck Typing Project while searching for infos about the DLR:

The duck typing library is a .NET class library written in C# that enables duck typing. Duck typing is a principle of dynamic typing in which an object’s current set of methods and properties determines the valid semantics, rather than its inheritance from a particular class. (For a detailed explanation, see the Wikipedia article.)

Beyond simple duck typing, this library has evolved to include different forms of variance in class members and other advanced features.

Very cool: “Although there is a performance hit when a new proxy type is generated, use of the casted object is virtually as fast to call as the object itself. Reflection.Emit is used to emit IL that directly calls the original object.”

Posted by Hartmut Wilms at 27.09.07 20:13