Returning an anonymous object with dynamic

suggest change

You can return an anonymous object from a method and read it through dynamic.

public static object FunctionWithUnknownReturnValues ()
{
    /// anonymous object
    return new { a = 1, b = 2 };
}

And assign the result to a dynamic object and read the values in it.

/// dynamic object
dynamic x = FunctionWithUnknownReturnValues();

Console.WriteLine(x.a);
Console.WriteLine(x.b);

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents