Posts Tagged ‘Dynamic’

.NET 4 Dynamic Types with Anonymous Types

March 6, 2010 Leave a comment

A post i wrote a while ago on pain with anonymous types has been totally rectified with the use of dynamic. How cool is the following code 🙂

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace V4Features
    class Program
        static void Main(string[] args)
            var customer = new
                Id = 1,
                Name = "Blair Davidson"

            List<dynamic> list = new List<dynamic> {customer};

            Console.WriteLine("Count: {0}", list.Count);


Not sure where I will use this yet but i will help work around a some hard issues im sure 🙂