Returning an anonymous object with dynamic
suggest changeYou 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);
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents