DCSIMG
PDC09 Day 1 – Dynamics in C# 4 - Alex Golesh's Blog About Silverlight Development

PDC09 Day 1 – Dynamics in C# 4

Switched to the Dynamics in C# 4 session. This session hall is not full at all… I’d rather say it is pretty empty… Probably this session is for real technology geeks like me :)

 

Did you know, that you cold create your own dynamic object by deriving from DynamicObject base class?

class Program
{
  static void Main(string[] args)
  {
    dynamic d = new myDynamic();
    Console.WriteLine(d++);
  }
}

class myDynamic : DynamicObject
{
  public override bool TryUnaryOperation(UnaryOperationBinder binder, out object result)
  {
    Console.WriteLine(binder.Operation);
    result = 25;
    return true;
  }
}

image

Nice :)

 

 

 

Stay tuned,

Alex

Published Tuesday, November 17, 2009 11:07 PM by Alex Golesh

Comments

No Comments

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Enter the numbers above: