C# Language "anonymous object" + "dynamic keyword" solution


Example

You can return an anonymous object from your function

public static object FunctionWithUnknowReturnValues ()
{
    /// 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 = FunctionWithUnknowReturnValues();

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