SyntaxHighlighter Build Test Page
Thoughts from a C# Developer
kennydust (gravatar)

Dynamic Typing in C# 4.0

I'm here at PDC 08 and attended a great session by Anders Hejlsberg for some of the things coming down the pipe for C# 4.0. One of the more exciting offerings is the idea of resolving names in your code at runtime instead of compile time via dynamic lookup. There is a new static Type called dynamic which it's usage pattern is such:

dynamic calc = new Calculator ();
int sum = calc.Add(10, 20);

In addition, it can be used in as a argument modifier for methods:

void RunCalculator(dynamic calc, int num1, int num2)
{
   calc.Add(num1, num2);
}

This is an incredibly powerful feature and Anders himself points out the evolution of C# is in dynamic programming. I guess the initial thought racing through my head is obvious -- what is the performance cost of using dynamics? I've always been against late-binding anything. More thoughts about this later.

0 Comments

Your Information
Mrs. Gravatar (gravatar)

<-- It's a gravatar

your comment