Beispiel #1
0
    static void Main()
    {
        object weaklyTyped   = CreateCheesecake();
        var    stronglyTyped = GrottyHacks.Cast(weaklyTyped,
                                                new { Fruit = "", Topping = "" });

        Console.WriteLine("Cheesecake: {0} ({1})",
                          stronglyTyped.Fruit, stronglyTyped.Topping);
    }
Beispiel #2
0
    static void Main()
    {
        object weaklyTyped   = CreateCheesecake();                                 //ANONYMOUS TYPE GENERATION
        var    stronglyTyped = GrottyHacks.Cast(weaklyTyped,
                                                new { Fruit = "", Topping = "" }); //"MAPPING"

        Console.WriteLine("Cheesecake: {0} ({1})",
                          stronglyTyped.Fruit, stronglyTyped.Topping);
    }