I have a function structurally similar to this one:
void Foo(dynamic arg1, dynamic arg2, out dynamic result) {
result = arg1 + arg2;
}
I'm using dynamic since this function should generically handle any type I throw at it.
But if I try to call it like so:
string Bar = null;
...
Foo("a", "b", out this.Bar);
I get an error message; I seemingly can't pass my pre-defined string Bar to the function (Cannot convert from 'out string' to 'out dynamic').
However, when I remove the 'out' keyword from the type declaration and my function call, everything works completely fine (I'm mentioning this to prove the point that everything else works perfectly fine).
I do not understand why the out modifier changes the whole situation, and dynamic suddenly can't be cast to a string, like I would be able to do it by implicitly assigning it as stated in the docs.
I'd gladly appreciate any help, there seemingly aren't a lot of people out there passing strings to a function expecting a dynamic with the out modifier...
void Foo<T>(dynamic arg1, dynamic arg2, out T result)and the rest is the sameFoo("a", "b", out this.Bar);it's because it can't be inferred...