{"id":3784,"date":"2014-03-30T05:36:53","date_gmt":"2014-03-30T05:36:53","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/c-4-0-project-targeting-earlier-framework-collection-of-common-programming-errors\/"},"modified":"2014-03-30T05:36:53","modified_gmt":"2014-03-30T05:36:53","slug":"c-4-0-project-targeting-earlier-framework-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/c-4-0-project-targeting-earlier-framework-collection-of-common-programming-errors\/","title":{"rendered":"C# 4.0 project targeting earlier framework-Collection of common programming errors"},"content":{"rendered":"<p>In the specific case of optional parameters, compatibility will work as default values to use are stored in the caller&#8217;s assembly and not in the called assembly so compatibility with other assemblies is ensured. If it compiles, it will run.<\/p>\n<p>Optional parameters are just a syntaxic sugar. The following code compiles and run for a target framework 2.0 :<\/p>\n<pre><code>internal class Program\n{\n    public static class DummyClass\n    {\n        public static string Bar(int b = 10, int a = 12)\n        {\n            return a.ToString();\n        }\n    }\n\n    private static void Main(string[] args)\n    {\n        Console.WriteLine(\"{0}\", DummyClass.Bar(a: 8));\n\n        Console.ReadKey();\n    }\n}\n<\/code><\/pre>\n<p>Read a full explanation by Mr Botelho<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the specific case of optional parameters, compatibility will work as default values to use are stored in the caller&#8217;s assembly and not in the called assembly so compatibility with other assemblies is ensured. If it compiles, it will run. Optional parameters are just a syntaxic sugar. The following code compiles and run for a [&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-3784","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3784","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=3784"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3784\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3784"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3784"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3784"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}