{"id":913,"date":"2023-03-05T00:33:50","date_gmt":"2023-03-05T00:33:50","guid":{"rendered":"https:\/\/www.naveedulhaq.com\/?p=913"},"modified":"2023-03-14T11:30:06","modified_gmt":"2023-03-14T11:30:06","slug":"switch-statement-in-c-explained","status":"publish","type":"post","link":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/switch-statement-in-c-explained\/","title":{"rendered":"Switch Statement in C# .NET 6 | Explained"},"content":{"rendered":"\n<p>In C#, the Switch statement is the type of control flow statement to compare a single expression with multiple values. If a value matches the test expression, then the specific block of code is executed. If the case does not match the expression, the compiler jumps to the next case. The purpose of the switch case statements is to simplify the code that requires multiple if-else statements.&nbsp;<\/p>\n\n\n\n<p>The purpose of this guide is to elaborate on the syntax and examples of the switch statement in C#.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How <strong>C# Switch<\/strong> works<\/h2>\n\n\n\n<p>The basic syntax of the switch statements in C# is as:&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>switch (exp)\n{\n     case &lt;val1&gt;;\n     &lt;Statement(s) of C# code&gt;\n     break;\n     case &lt;val2&gt;;\n     &lt;Statement(s) of C# code&gt;\n     break;\n     default;\n     &lt;Statement(s) of C# code&gt;\n     break;      \n}<\/code><\/pre>\n\n\n\n<p>The description of the syntax is:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The expression is defined after the \u201c<strong>switch<\/strong>\u201d keyword as shown above. The \u201c<strong>exp<\/strong>\u201d can be a variable or any condition, i.e., integer, string, or condition.<\/li>\n\n\n\n<li>The main body defines the cases using the \u201ccase\u201d keyword. After each case, the statements of the C# code are executed.&nbsp;<\/li>\n\n\n\n<li>After the statements, the \u201c<strong>break<\/strong>\u201d keyword occurs, which breaks the flow if that specific case matches the \u201c<strong>exp<\/strong>\u201d.<\/li>\n\n\n\n<li>Once all the statements are matched, then the \u201c<strong>default<\/strong>\u201d comes into play which also carries some code statements. This piece of code is executed if none of the cases matches the \u201c<strong>exp<\/strong>\u201d value.<\/li>\n<\/ul>\n\n\n\n<p><strong>Note: <\/strong>There could be multiple case statements as per the requirement of the situation<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Examples of Switch Case Statement in C#<\/strong><\/h2>\n\n\n\n<p>Here, a few examples are explained to demonstrate the usage of the switch case statement in C#.&nbsp;<\/p>\n\n\n\n<p><strong>Example 1: Switch Case on a Numeric Value<\/strong><\/p>\n\n\n\n<p>As discussed earlier, the expression can be an integer, string, float, char, etc. In this example, the \u201c<strong>expression<\/strong>\u201d will be a numeric value, and the cases will be matched in each case.&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>using System;\n    public class NVBlog {\n       public static void Main(string&#91;] args)  {\n            int z = 7;\n            switch (z)\n            {\n            case 1:\n                Console.WriteLine(\"The Value is True\");\n            break;\n            case 3:\n                Console.WriteLine(\"The Value is 3\");\n            break;\n            case 5:\n                Console.WriteLine(\"The Value is 5\");\n            break;\n            case 7:\n                Console.WriteLine(\"The Value is 7\");\n            break;\n        }    \n    }\n} \n<\/code><\/pre>\n\n\n\n<p>In the code:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>An integer is initialized \u201c<strong>z=7<\/strong>\u201d and used as an expression in the switch.<\/li>\n\n\n\n<li>There are a total of four cases, i.e., case 1, case 3, case 5, and case 7. The compiler checks each case and continues to the other until it matches \u201c<strong>case 7<\/strong>\u201d.<\/li>\n<\/ul>\n\n\n\n<p>Output<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"828\" height=\"170\" src=\"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2023\/03\/switch-statement-in-c-sharp.png\" loading=\"lazy\" alt=\"switch statement in c sharp\" class=\"wp-image-915\" srcset=\"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2023\/03\/switch-statement-in-c-sharp.png 828w, https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2023\/03\/switch-statement-in-c-sharp-300x62.png 300w, https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2023\/03\/switch-statement-in-c-sharp-768x158.png 768w\" sizes=\"auto, (max-width: 828px) 100vw, 828px\" \/><\/figure>\n\n\n\n<p>The statement matching \u201ccase 7\u201c has been printed.<\/p>\n\n\n\n<p><strong>Example 2: The default Case in the Switch Statement&nbsp;<\/strong><\/p>\n\n\n\n<p>Now, let\u2019s understand the functionality of the default case in the switch statement.&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>using System;\n    public class NVBlog {\n        public static void Main(string&#91;] args)  {\n            String t = \"Naveed Ul Haq\";\n            switch (t)\n            {\n            case \"Naveed\":\n                Console.WriteLine(\"The expression's value is Naveed\");\n            break;\n            case \"Ul Haq\":\n                Console.WriteLine(\"The expression's value is Ul Haq\");\n            break;\n            default:\n                Console.WriteLine(\"Hey! Welcome to Naveed Ul Haq Blog\");\n            break;\n        }    \n    }\n}\n<\/code><\/pre>\n\n\n\n<p>The code\u2019s explanation is:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A string variable is initialized to be used as an expression in the \u201c<strong>switch<\/strong>\u201d.<\/li>\n\n\n\n<li>Two cases containing the values \u201c<strong>Naveed<\/strong>\u201d and \u201c<strong>Ul Haq<\/strong>\u2018 are checked.<\/li>\n\n\n\n<li>Lastly, there is a print statement inside the \u201c<strong>default<\/strong>\u201d keyword to be used if none of the cases matches the switch expression.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"832\" height=\"158\" src=\"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2023\/03\/switch-statement-in-c-sharp-2.png\" loading=\"lazy\" alt=\"switch statement in c sharp\" class=\"wp-image-916\" srcset=\"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2023\/03\/switch-statement-in-c-sharp-2.png 832w, https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2023\/03\/switch-statement-in-c-sharp-2-300x57.png 300w, https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2023\/03\/switch-statement-in-c-sharp-2-768x146.png 768w\" sizes=\"auto, (max-width: 832px) 100vw, 832px\" \/><\/figure>\n\n\n\n<p>As the output shows that the code statement inside the \u201cdefault\u201d case is printed on the console.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Wrap up&nbsp;<\/strong><\/h2>\n\n\n\n<p>In C# for any programming language, switch statements can make code easier to read and understand, especially when dealing with a large number of possible values. By the end, you have learned the purpose of the switch case statement with the help of various examples.<\/p>\n\n\n\n<p>If you want to learn how to format strings in C#, please look at my blog on <a href=\"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/format-strings-in-csharp\/\">C# String Format<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In C#, the Switch statement is the type of control flow statement to compare a single expression with multiple values. If a value matches the&#8230;<\/p>\n","protected":false},"author":3,"featured_media":641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[11,8,62,37,32,23],"class_list":["post-913","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dot-net-core","tag-dot-net-core","tag-dot-net-framework","tag-asp-net","tag-c","tag-developer","tag-development"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Switch Statement in C# .NET 6 | Explained - Naveed Ul-Haq&#039;s blog<\/title>\n<meta name=\"description\" content=\"C# Switch - The purpose of this guide is to elaborate on the syntax and examples of the switch statement in C#. Naveed Ul-Haq&#039;s blog\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/switch-statement-in-c-explained\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Switch Statement in C# .NET 6 | Explained - Naveed Ul-Haq&#039;s blog\" \/>\n<meta property=\"og:description\" content=\"C# Switch - The purpose of this guide is to elaborate on the syntax and examples of the switch statement in C#. Naveed Ul-Haq&#039;s blog\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/switch-statement-in-c-explained\/\" \/>\n<meta property=\"og:site_name\" content=\"Naveed Ul-Haq&#039;s blog\" \/>\n<meta property=\"article:published_time\" content=\"2023-03-05T00:33:50+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-03-14T11:30:06+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2021\/11\/240px-.NET_Logo.svg_.png\" \/>\n\t<meta property=\"og:image:width\" content=\"240\" \/>\n\t<meta property=\"og:image:height\" content=\"240\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Abdul Mannan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Abdul Mannan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/switch-statement-in-c-explained\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/switch-statement-in-c-explained\\\/\"},\"author\":{\"name\":\"Abdul Mannan\",\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/#\\\/schema\\\/person\\\/8babf3cd198e47e5c727f67880ea7977\"},\"headline\":\"Switch Statement in C# .NET 6 | Explained\",\"datePublished\":\"2023-03-05T00:33:50+00:00\",\"dateModified\":\"2023-03-14T11:30:06+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/switch-statement-in-c-explained\\\/\"},\"wordCount\":506,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/#\\\/schema\\\/person\\\/dd6db5980b965fcae41e096d357c65c9\"},\"image\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/switch-statement-in-c-explained\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.naveedulhaq.com\\\/wp-content\\\/uploads\\\/2021\\\/11\\\/240px-.NET_Logo.svg_.png\",\"keywords\":[\".net core\",\".net framework\",\"asp.net\",\"c#\",\"developer\",\"development\"],\"articleSection\":[\".NET\"],\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/switch-statement-in-c-explained\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/switch-statement-in-c-explained\\\/\",\"url\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/switch-statement-in-c-explained\\\/\",\"name\":\"Switch Statement in C# .NET 6 | Explained - Naveed Ul-Haq&#039;s blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/switch-statement-in-c-explained\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/switch-statement-in-c-explained\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.naveedulhaq.com\\\/wp-content\\\/uploads\\\/2021\\\/11\\\/240px-.NET_Logo.svg_.png\",\"datePublished\":\"2023-03-05T00:33:50+00:00\",\"dateModified\":\"2023-03-14T11:30:06+00:00\",\"description\":\"C# Switch - The purpose of this guide is to elaborate on the syntax and examples of the switch statement in C#. Naveed Ul-Haq&#039;s blog\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/switch-statement-in-c-explained\\\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/switch-statement-in-c-explained\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/switch-statement-in-c-explained\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.naveedulhaq.com\\\/wp-content\\\/uploads\\\/2021\\\/11\\\/240px-.NET_Logo.svg_.png\",\"contentUrl\":\"https:\\\/\\\/www.naveedulhaq.com\\\/wp-content\\\/uploads\\\/2021\\\/11\\\/240px-.NET_Logo.svg_.png\",\"width\":240,\"height\":240,\"caption\":\".net\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/switch-statement-in-c-explained\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.naveedulhaq.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Switch Statement in C# .NET 6 | Explained\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/#website\",\"url\":\"https:\\\/\\\/www.naveedulhaq.com\\\/\",\"name\":\"Naveed Ul-Haq's blog\",\"description\":\"AI, Optimizely, Azure &amp; more\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/#\\\/schema\\\/person\\\/dd6db5980b965fcae41e096d357c65c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.naveedulhaq.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/#\\\/schema\\\/person\\\/dd6db5980b965fcae41e096d357c65c9\",\"name\":\"Naveed Ul-Haq\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/362536aba6cc66917d7558cacd015a81c7cdf1a69b9a28c994764847c487b692?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/362536aba6cc66917d7558cacd015a81c7cdf1a69b9a28c994764847c487b692?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/362536aba6cc66917d7558cacd015a81c7cdf1a69b9a28c994764847c487b692?s=96&d=mm&r=g\",\"caption\":\"Naveed Ul-Haq\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/362536aba6cc66917d7558cacd015a81c7cdf1a69b9a28c994764847c487b692?s=96&d=mm&r=g\"},\"description\":\"I lead engineering delivery teams for digital commerce and digital experience platforms, combining hands-on architecture experience with strong delivery governance. Over 20+ years, I\u2019ve built and led cross\u2011functional teams (engineering, BA, QA) delivering modern cloud solutions on Azure, microservices, APIs and eCommerce\\\/CMS platforms. My recent focus includes AI-enabled commerce automation: product ingestion and enrichment workflows, content optimisation for SEO and shopping feeds, and agentic tooling to improve marketing and accessibility workflows. I\u2019m passionate about building high-performing teams, establishing quality\\\/release standards, and delivering measurable outcomes across performance, reliability, and speed of change.\",\"sameAs\":[\"https:\\\/\\\/www.naveedulhaq.com\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/naveedulhaq\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/#\\\/schema\\\/person\\\/8babf3cd198e47e5c727f67880ea7977\",\"name\":\"Abdul Mannan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/7021bf97f2da3c29882f0e194e341d6abcc2b18abbbbf1e8ea688017b2323d21?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/7021bf97f2da3c29882f0e194e341d6abcc2b18abbbbf1e8ea688017b2323d21?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/7021bf97f2da3c29882f0e194e341d6abcc2b18abbbbf1e8ea688017b2323d21?s=96&d=mm&r=g\",\"caption\":\"Abdul Mannan\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Switch Statement in C# .NET 6 | Explained - Naveed Ul-Haq&#039;s blog","description":"C# Switch - The purpose of this guide is to elaborate on the syntax and examples of the switch statement in C#. Naveed Ul-Haq&#039;s blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/switch-statement-in-c-explained\/","og_locale":"en_GB","og_type":"article","og_title":"Switch Statement in C# .NET 6 | Explained - Naveed Ul-Haq&#039;s blog","og_description":"C# Switch - The purpose of this guide is to elaborate on the syntax and examples of the switch statement in C#. Naveed Ul-Haq&#039;s blog","og_url":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/switch-statement-in-c-explained\/","og_site_name":"Naveed Ul-Haq&#039;s blog","article_published_time":"2023-03-05T00:33:50+00:00","article_modified_time":"2023-03-14T11:30:06+00:00","og_image":[{"width":240,"height":240,"url":"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2021\/11\/240px-.NET_Logo.svg_.png","type":"image\/png"}],"author":"Abdul Mannan","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Abdul Mannan","Estimated reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/switch-statement-in-c-explained\/#article","isPartOf":{"@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/switch-statement-in-c-explained\/"},"author":{"name":"Abdul Mannan","@id":"https:\/\/www.naveedulhaq.com\/#\/schema\/person\/8babf3cd198e47e5c727f67880ea7977"},"headline":"Switch Statement in C# .NET 6 | Explained","datePublished":"2023-03-05T00:33:50+00:00","dateModified":"2023-03-14T11:30:06+00:00","mainEntityOfPage":{"@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/switch-statement-in-c-explained\/"},"wordCount":506,"commentCount":0,"publisher":{"@id":"https:\/\/www.naveedulhaq.com\/#\/schema\/person\/dd6db5980b965fcae41e096d357c65c9"},"image":{"@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/switch-statement-in-c-explained\/#primaryimage"},"thumbnailUrl":"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2021\/11\/240px-.NET_Logo.svg_.png","keywords":[".net core",".net framework","asp.net","c#","developer","development"],"articleSection":[".NET"],"inLanguage":"en-GB","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/switch-statement-in-c-explained\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/switch-statement-in-c-explained\/","url":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/switch-statement-in-c-explained\/","name":"Switch Statement in C# .NET 6 | Explained - Naveed Ul-Haq&#039;s blog","isPartOf":{"@id":"https:\/\/www.naveedulhaq.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/switch-statement-in-c-explained\/#primaryimage"},"image":{"@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/switch-statement-in-c-explained\/#primaryimage"},"thumbnailUrl":"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2021\/11\/240px-.NET_Logo.svg_.png","datePublished":"2023-03-05T00:33:50+00:00","dateModified":"2023-03-14T11:30:06+00:00","description":"C# Switch - The purpose of this guide is to elaborate on the syntax and examples of the switch statement in C#. Naveed Ul-Haq&#039;s blog","breadcrumb":{"@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/switch-statement-in-c-explained\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/switch-statement-in-c-explained\/"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/switch-statement-in-c-explained\/#primaryimage","url":"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2021\/11\/240px-.NET_Logo.svg_.png","contentUrl":"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2021\/11\/240px-.NET_Logo.svg_.png","width":240,"height":240,"caption":".net"},{"@type":"BreadcrumbList","@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/switch-statement-in-c-explained\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.naveedulhaq.com\/"},{"@type":"ListItem","position":2,"name":"Switch Statement in C# .NET 6 | Explained"}]},{"@type":"WebSite","@id":"https:\/\/www.naveedulhaq.com\/#website","url":"https:\/\/www.naveedulhaq.com\/","name":"Naveed Ul-Haq's blog","description":"AI, Optimizely, Azure &amp; more","publisher":{"@id":"https:\/\/www.naveedulhaq.com\/#\/schema\/person\/dd6db5980b965fcae41e096d357c65c9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.naveedulhaq.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":["Person","Organization"],"@id":"https:\/\/www.naveedulhaq.com\/#\/schema\/person\/dd6db5980b965fcae41e096d357c65c9","name":"Naveed Ul-Haq","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/secure.gravatar.com\/avatar\/362536aba6cc66917d7558cacd015a81c7cdf1a69b9a28c994764847c487b692?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/362536aba6cc66917d7558cacd015a81c7cdf1a69b9a28c994764847c487b692?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/362536aba6cc66917d7558cacd015a81c7cdf1a69b9a28c994764847c487b692?s=96&d=mm&r=g","caption":"Naveed Ul-Haq"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/362536aba6cc66917d7558cacd015a81c7cdf1a69b9a28c994764847c487b692?s=96&d=mm&r=g"},"description":"I lead engineering delivery teams for digital commerce and digital experience platforms, combining hands-on architecture experience with strong delivery governance. Over 20+ years, I\u2019ve built and led cross\u2011functional teams (engineering, BA, QA) delivering modern cloud solutions on Azure, microservices, APIs and eCommerce\/CMS platforms. My recent focus includes AI-enabled commerce automation: product ingestion and enrichment workflows, content optimisation for SEO and shopping feeds, and agentic tooling to improve marketing and accessibility workflows. I\u2019m passionate about building high-performing teams, establishing quality\/release standards, and delivering measurable outcomes across performance, reliability, and speed of change.","sameAs":["https:\/\/www.naveedulhaq.com","https:\/\/www.linkedin.com\/in\/naveedulhaq\/"]},{"@type":"Person","@id":"https:\/\/www.naveedulhaq.com\/#\/schema\/person\/8babf3cd198e47e5c727f67880ea7977","name":"Abdul Mannan","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/secure.gravatar.com\/avatar\/7021bf97f2da3c29882f0e194e341d6abcc2b18abbbbf1e8ea688017b2323d21?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/7021bf97f2da3c29882f0e194e341d6abcc2b18abbbbf1e8ea688017b2323d21?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/7021bf97f2da3c29882f0e194e341d6abcc2b18abbbbf1e8ea688017b2323d21?s=96&d=mm&r=g","caption":"Abdul Mannan"}}]}},"_links":{"self":[{"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/posts\/913","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/comments?post=913"}],"version-history":[{"count":0,"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/posts\/913\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/media\/641"}],"wp:attachment":[{"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/media?parent=913"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/categories?post=913"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/tags?post=913"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}