'Tuple return dynamic in c# while passing parameter as dynamic
Solution 1:[1]
Should it not it gives build error while Tuple is not return type of both method?
No, it should not. As msdn docs says:
C# 4 introduces a new type, dynamic. The type is a static type, but an object of type dynamic bypasses static type checking. At compile time, an element that is typed as dynamic is assumed to support any operation. However, if the code is not valid, errors are caught at run time.
This is a reason why your Build succeeded.
However, it will throw an exception at runtime.
So your compiler assumes that you can do any operation as dynamic is used as an argument in your function. And this is a reason why compiler builds successfully. However, at runtime it will throw an error something like this:
Cannot implicitly convert type
System.Tuple<int>toCup
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |

