C# 4.0: Mit dynamic anonyme Typen zurückgeben und verwenden

Monday, October 27, 2008 11:05:46 PM (W. Europe Standard Time, UTC+01:00)

Interessant was jetzt geht:

static void Main(string[] args)
{
    Console.WriteLine(Test().Hello);
    Console.WriteLine(Test().World);
}

static dynamic Test()
{
    return new { Hello = "Hallo", World = "Welt" };
}

Das funktioniert tatsächlich so. Die Kombination “static dynamic” liest sich allerdings etwas merkwürdig :-).

Technorati-Tags: ,
Comments are closed.