{
    "componentChunkName": "component---src-templates-blog-tsx",
    "path": "/blog/index.php/2009/11/11/csharp-4-supports-default-values-for-optional-method-parameters/",
    "result": {"data":{"mdx":{"body":"var _excluded = [\"components\"];\n\nfunction _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\n/* @jsxRuntime classic */\n\n/* @jsx mdx */\nvar _frontmatter = {\n  \"title\": \"C# 4.0 supports optional parameters\",\n  \"date\": \"2009-11-11T00:00:00.000Z\",\n  \"image\": \"./image.jpg\",\n  \"banner\": \"./banner.jpg\",\n  \"description\": \"As of C# 4.0 you use can use optional parameters.\"\n};\nvar layoutProps = {\n  _frontmatter: _frontmatter\n};\nvar MDXLayout = \"wrapper\";\nreturn function MDXContent(_ref) {\n  var components = _ref.components,\n      props = _objectWithoutProperties(_ref, _excluded);\n\n  return mdx(MDXLayout, _extends({}, layoutProps, props, {\n    components: components,\n    mdxType: \"MDXLayout\"\n  }), mdx(\"p\", null, \"In VB.NET you have always been able to use optional parameters:\"), mdx(\"deckgo-highlight-code\", {\n    \"language\": \"vb\",\n    \"terminal\": \"carbon\",\n    \"theme\": \"vscode\",\n    \"line-numbers\": \"true\"\n  }, \"\\n          \", mdx(\"code\", {\n    parentName: \"deckgo-highlight-code\",\n    \"slot\": \"code\"\n  }, \"Sub Foo(ByVal p1 As String, Optional ByVal p2 As String = \\\"default value\\\")\\nEnd Sub\\n\\n'Call to Foo with 1 of the 2 parameters is allowed\\nFoo(\\\"p1 value\\\")\"), \"\\n        \"), mdx(\"p\", null, \"Now in C# 4.0 we get the same support:\"), mdx(\"deckgo-highlight-code\", {\n    \"language\": \"csharp\",\n    \"terminal\": \"carbon\",\n    \"theme\": \"vscode\",\n    \"line-numbers\": \"true\"\n  }, \"\\n          \", mdx(\"code\", {\n    parentName: \"deckgo-highlight-code\",\n    \"slot\": \"code\"\n  }, \"void Foo(string p1, string p2 = \\\"default value\\\")\\n{\\n}\\n\\n//Call to Foo with 1 of the 2 parameters is allowed\\nFoo(\\\"p1 value\\\");\"), \"\\n        \"), mdx(\"p\", null, \"Although in C# now, we can still achieve the same using overloads.  The example above just gives us another option. Equivalent C# 1.0 - 3.5 overload example:\"), mdx(\"deckgo-highlight-code\", {\n    \"language\": \"csharp\",\n    \"terminal\": \"carbon\",\n    \"theme\": \"vscode\",\n    \"line-numbers\": \"true\"\n  }, \"\\n          \", mdx(\"code\", {\n    parentName: \"deckgo-highlight-code\",\n    \"slot\": \"code\"\n  }, \"void Foo(string p1)\\n{\\n    Foo(p1, \\\"default value\\\");\\n}\\n\\nvoid Foo(string p1, string p2)\\n{\\n}\\n\\n//Call to Foo with 1 of the 2 parameters is allowed\\nFoo(\\\"p1 value\\\");\"), \"\\n        \"), mdx(\"p\", null, \"I don't think this will make a great deal of difference to me (might make COM Interop easier).  However I think when used in the right situations, it might make code more readable - for example replacing redundant overloads.\"));\n}\n;\nMDXContent.isMDXComponent = true;","frontmatter":{"title":"C# 4.0 supports optional parameters","date":"11 November 2009","description":"As of C# 4.0 you use can use optional parameters.","banner":{"publicURL":"/static/ecf8f53b24322229b96c428ebd757fb7/banner.jpg","childImageSharp":{"fluid":{"srcSet":"/static/ecf8f53b24322229b96c428ebd757fb7/d34c9/banner.jpg 480w,\n/static/ecf8f53b24322229b96c428ebd757fb7/f7c79/banner.jpg 960w,\n/static/ecf8f53b24322229b96c428ebd757fb7/85bc9/banner.jpg 1920w","base64":"data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAIABQDASIAAhEBAxEB/8QAFwABAAMAAAAAAAAAAAAAAAAAAAECA//EABYBAQEBAAAAAAAAAAAAAAAAAAIAAf/aAAwDAQACEAMQAAABxoYpDv/EABgQAAMBAQAAAAAAAAAAAAAAAAECAxEh/9oACAEBAAEFAp683aswH5//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAEDAQE/AT//xAAWEQEBAQAAAAAAAAAAAAAAAAAAARH/2gAIAQIBAT8Bla//xAAcEAACAAcAAAAAAAAAAAAAAAAAARESISIyYXL/2gAIAQEABj8CsljtixXJVn//xAAbEAEAAgIDAAAAAAAAAAAAAAABACERMUFRkf/aAAgBAQABPyG0BFdxGhbuW5Syr5P/2gAMAwEAAgADAAAAEAv/AP/EABURAQEAAAAAAAAAAAAAAAAAABAR/9oACAEDAQE/EIf/xAAVEQEBAAAAAAAAAAAAAAAAAAABAP/aAAgBAgEBPxBIV//EABkQAQADAQEAAAAAAAAAAAAAAAEAESFBMf/aAAgBAQABPxCwQW+ZuPmyoaOklVdliMwVAj//2Q==","aspectRatio":2.4,"src":"/static/ecf8f53b24322229b96c428ebd757fb7/85bc9/banner.jpg","sizes":"(max-width: 1920px) 100vw, 1920px"},"id":"96213086-e254-56f3-b903-b32cbbb0ed7c"}}}}},"pageContext":{"slug":"/blog/index.php/2009/11/11/csharp-4-supports-default-values-for-optional-method-parameters/"}},
    "staticQueryHashes": ["1139857438","1946588481","2083862410","2213455283","2418326273","2840686334","3067102388"]}