My best guess is that you are allowed to return dynamic
so that you could do this:
private static dynamic Get() {
return new {X=5};
}
public static void Main() {
var v = Get();
Console.WriteLine(v.X);
}
If you could declare Get
only as object Get()
, then your callers would be forced to replace var
with dynamic
: otherwise, the code would not compile.
Same goes for a use case without var
:
public static void Main() {
Console.WriteLine(Get().X);
}
without dynamic
return type you would have to do an intermediate assignment, or use a cast to dynamic
.