3
當使用ValueTuple
和動態對象時,我收到這個奇怪的CS8133錯誤。我傳遞動態對象作爲輸入並將ValueTuple作爲輸出。他們爲什麼互相影響。爲什麼這個編譯器錯誤混合C#ValueTuple和動態時
public static (string, string) foo(dynamic input)
{
return ("", "");
}
public void foo_test()
{
dynamic input = new { a = "", b = "" };
(string v1, string v2) = foo(new { a = "", b = "" }); //compiles fine
(string v3, string v4) = foo(input); //CS8133 Cannot deconstruct dynamic objects
var result = foo(input); //compiles fine
}
編輯: 的錯誤信息是:CS8133 Cannot deconstruct dynamic objects
什麼是錯誤信息? –
'foo(input)' - >'foo((object)input)' – PetSerAl
@PetSerAl但是爲什麼。爲什麼編譯器只在第二次調用時報告錯誤 –