1
シンプルコード:奇妙なダイナミック型パラメータの問題
class Program
{
static void Main(string[] args)
{
dynamic income = "test";
var result = Test(income); // Why dynamic?
Test2(result); // WTF?
}
static string Test(string income)
{
return income;
}
static string Test2(int income)
{
return income.ToString();
}
}
上記のコードはエラーなしでコンパイルし、実行時に例外を除いて実行されます。An unhandled exception of type Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' occurred in System.Core.dll
result
がdynamic
タイプとして決定される理由を誰もが説明できますか?
どこに文書化されていますか? –
これは 'dynamic'のコア動作の一部です。そのドキュメントを見てください。 – SLaks