{"id":4028,"date":"2014-03-30T07:16:36","date_gmt":"2014-03-30T07:16:36","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/method-overloading-and-dynamic-keyword-in-c-collection-of-common-programming-errors\/"},"modified":"2014-03-30T07:16:36","modified_gmt":"2014-03-30T07:16:36","slug":"method-overloading-and-dynamic-keyword-in-c-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/method-overloading-and-dynamic-keyword-in-c-collection-of-common-programming-errors\/","title":{"rendered":"method overloading and dynamic keyword in C#-Collection of common programming errors"},"content":{"rendered":"<p>I still haven&#8217;t upgraded to 4.0 else I would have checked the code snippet myself. But I hope some expert can comment on this.<\/p>\n<p>In following code, will the appropriate <code>Print()<\/code> method be called at runtime? Is it even legal in C# 2010 to call it that way?<\/p>\n<pre><code>public void Test()\n{\n    dynamic objX = InstantiateAsStringOrDouble();\n\n    Print(objX);\n}\n\npublic void Print(string s)\n{\n    Console.Write(\"string\");\n}\n\npublic void Print(double n)\n{\n    Console.Write(\"double\");\n}\n<\/code><\/pre>\n<p>Thanks!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I still haven&#8217;t upgraded to 4.0 else I would have checked the code snippet myself. But I hope some expert can comment on this. In following code, will the appropriate Print() method be called at runtime? Is it even legal in C# 2010 to call it that way? public void Test() { dynamic objX = [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4028","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4028","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4028"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4028\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4028"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4028"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4028"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}