{"id":1066,"date":"2023-04-17T09:00:00","date_gmt":"2023-04-17T09:00:00","guid":{"rendered":"https:\/\/www.naveedulhaq.com\/?p=1066"},"modified":"2023-04-09T16:50:28","modified_gmt":"2023-04-09T16:50:28","slug":"create-and-use-dictionary-in-c","status":"publish","type":"post","link":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/create-and-use-dictionary-in-c\/","title":{"rendered":"How to Create and Use Dictionary in C#?"},"content":{"rendered":"\n<p>When I started learning about Data Structures in programming, dictionaries, in particular, intrigued me a lot. And that is exactly why we will explore one of the most powerful data structures in <a href=\"https:\/\/learn.microsoft.com\/en-us\/dotnet\/\" target=\"_blank\" rel=\"noreferrer noopener\">C#<\/a>: the dictionary. Whether looking to store and access key-value pairs or perform fast lookups and retrievals, dictionaries are essential in any C# programmer&#8217;s arsenal.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"250\" src=\"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2023\/04\/template-e1680902247271-1024x250.png\" loading=\"lazy\" alt=\"\" class=\"wp-image-1069\" srcset=\"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2023\/04\/template-e1680902247271-1024x250.png 1024w, https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2023\/04\/template-e1680902247271-300x73.png 300w, https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2023\/04\/template-e1680902247271-768x188.png 768w, https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2023\/04\/template-e1680902247271.png 1280w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">What is a Dictionary in C#?<\/h2>\n\n\n\n<p>At its core, a dictionary is a collection of <strong>key-value<\/strong> pairs, where each key is associated with a <strong>unique value<\/strong>. Dictionaries allow you to quickly and easily access and retrieve data based on its corresponding key.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Create a Dictionary in C#?<\/h2>\n\n\n\n<p>Let&#8217;s start by creating a dictionary in C#. Here&#8217;s the basic syntax for creating a new dictionary:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Dictionary&lt;string, int&gt; myDictionary = new Dictionary&lt;string, int&gt;();<\/code><\/pre>\n\n\n\n<p>In this example, we&#8217;re creating a new dictionary that will store <strong>strings as keys and integers as values<\/strong>. Of course, you can customize this to fit your specific use case.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Adding Key-Value Pairs to a Dictionary<\/h2>\n\n\n\n<p>Now that we&#8217;ve created a dictionary let&#8217;s add key-value pairs. There are two ways to add key-value pairs to a dictionary:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Using the Add() Method<\/h3>\n\n\n\n<p>Here&#8217;s how to add a new key-value pair to a dictionary using the <strong>Add()<\/strong> method:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>myDictionary.Add(\"apple\", 5);<\/code><\/pre>\n\n\n\n<p>In this example, we&#8217;re adding a new key-value pair to our dictionary: the key &#8220;apple&#8221; is associated with the value 5.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Using the Indexer<\/h3>\n\n\n\n<p>Alternatively, you can add a new key-value pair to a dictionary using the <strong>indexer<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>myDictionary&#091;\"banana\"] = 2;<\/code><\/pre>\n\n\n\n<p>In this example, we add a new key-value pair to our dictionary: the key &#8220;<strong>banana<\/strong>&#8221; is associated with the value <strong>2<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Retrieve Values from a Dictionary in C#<\/h2>\n\n\n\n<p>Of course, adding key-value pairs to a dictionary is just the beginning. The real power of dictionaries comes from their <strong>ability to quickly and efficiently retrieve values<\/strong> based on their corresponding keys. Here&#8217;s how to retrieve a value from a dictionary:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int value = myDictionary&#091;\"apple\"];<\/code><\/pre>\n\n\n\n<p>In this example, we&#8217;re retrieving the value associated with the key &#8220;<strong>apple<\/strong>&#8221; from our dictionary. To get output, follow all the above lines that are mentioned, and then add the following line at the end:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Console.Write(value);<\/code><\/pre>\n\n\n\n<p>At this point, the terminal will display the value as \u201c<strong>5<\/strong>,\u201d meaning you have successfully retrieved the value from the dictionary.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Checking for Key Existence<\/h2>\n\n\n\n<p>Before retrieving a value from a dictionary, you should always check whether the key exists. You can do this using the <strong>ContainsKey()<\/strong> method:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if (myDictionary.ContainsKey(\"apple\"))<br>{<br>int value = myDictionary&#091;\"apple\"];<br>\/\/ do something with the value<br>}<\/code><\/pre>\n\n\n\n<p>In this example, we check whether the key &#8220;<strong>apple<\/strong>&#8221; exists in our dictionary before retrieving its corresponding value. If you print out the value of the \u201c<strong>value<\/strong>\u201d variable within the <strong>if-clause<\/strong>, then the terminal will show the output as \u201c<strong>5<\/strong>\u201d<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Dictionary Properties<\/h2>\n\n\n\n<p>Dictionaries have <strong>several useful properties<\/strong> that you can use to access information about them:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Count<\/h3>\n\n\n\n<p>The <strong>Count property returns the number<\/strong> of key-value pairs in the dictionary:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int count = myDictionary.Count;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Keys<\/h3>\n\n\n\n<p>The <strong>Keys property returns a collection of all the keys<\/strong> in the dictionary:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>foreach (string key in myDictionary.Keys)<br>{<br>Console.WriteLine(key);<br>}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Values<\/h3>\n\n\n\n<p>The <strong>Values property returns a collection of all the values<\/strong> in the dictionary:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>foreach (int value in myDictionary.Values)<br>{<br>Console.WriteLine(value);<br>}<\/code><\/pre>\n\n\n\n<p>And there you have it. With these simple steps and examples, you can confidently c<strong>reate and use dictionaries<\/strong> in your C# code. Whether building a complex application or experimenting with a new data structure, dictionaries offer a powerful and efficient way to store and retrieve key-value pairs. <a href=\"https:\/\/www.naveedulhaq.com\/index.php\/category\/dot-net-core\/\" target=\"_blank\" rel=\"noreferrer noopener\">Read more C# &amp; .NET Tutorials!<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A Dictionary in C# is a collection of key-value pairs, where each key is associated with a unique value providing and easy and quick retrieval.<\/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,56],"class_list":["post-1066","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-visual-studio"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Create and Use Dictionary in C#? - Naveed Ul-Haq&#039;s blog<\/title>\n<meta name=\"description\" content=\"A Dictionary in C# is a collection of key-value pairs, where each key is associated with a unique value providing and easy and quick retrieval.\" \/>\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\/create-and-use-dictionary-in-c\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Create and Use Dictionary in C#? - Naveed Ul-Haq&#039;s blog\" \/>\n<meta property=\"og:description\" content=\"A Dictionary in C# is a collection of key-value pairs, where each key is associated with a unique value providing and easy and quick retrieval.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/create-and-use-dictionary-in-c\/\" \/>\n<meta property=\"og:site_name\" content=\"Naveed Ul-Haq&#039;s blog\" \/>\n<meta property=\"article:published_time\" content=\"2023-04-17T09:00:00+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=\"3 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\\\/create-and-use-dictionary-in-c\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/create-and-use-dictionary-in-c\\\/\"},\"author\":{\"name\":\"Abdul Mannan\",\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/#\\\/schema\\\/person\\\/8babf3cd198e47e5c727f67880ea7977\"},\"headline\":\"How to Create and Use Dictionary in C#?\",\"datePublished\":\"2023-04-17T09:00:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/create-and-use-dictionary-in-c\\\/\"},\"wordCount\":555,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/#\\\/schema\\\/person\\\/dd6db5980b965fcae41e096d357c65c9\"},\"image\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/create-and-use-dictionary-in-c\\\/#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\",\"visual-studio\"],\"articleSection\":[\".NET\"],\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/create-and-use-dictionary-in-c\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/create-and-use-dictionary-in-c\\\/\",\"url\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/create-and-use-dictionary-in-c\\\/\",\"name\":\"How to Create and Use Dictionary in C#? - Naveed Ul-Haq&#039;s blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/create-and-use-dictionary-in-c\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/create-and-use-dictionary-in-c\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.naveedulhaq.com\\\/wp-content\\\/uploads\\\/2021\\\/11\\\/240px-.NET_Logo.svg_.png\",\"datePublished\":\"2023-04-17T09:00:00+00:00\",\"description\":\"A Dictionary in C# is a collection of key-value pairs, where each key is associated with a unique value providing and easy and quick retrieval.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/create-and-use-dictionary-in-c\\\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/create-and-use-dictionary-in-c\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/www.naveedulhaq.com\\\/index.php\\\/dot-net-core\\\/create-and-use-dictionary-in-c\\\/#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\\\/create-and-use-dictionary-in-c\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.naveedulhaq.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Create and Use Dictionary in C#?\"}]},{\"@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":"How to Create and Use Dictionary in C#? - Naveed Ul-Haq&#039;s blog","description":"A Dictionary in C# is a collection of key-value pairs, where each key is associated with a unique value providing and easy and quick retrieval.","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\/create-and-use-dictionary-in-c\/","og_locale":"en_GB","og_type":"article","og_title":"How to Create and Use Dictionary in C#? - Naveed Ul-Haq&#039;s blog","og_description":"A Dictionary in C# is a collection of key-value pairs, where each key is associated with a unique value providing and easy and quick retrieval.","og_url":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/create-and-use-dictionary-in-c\/","og_site_name":"Naveed Ul-Haq&#039;s blog","article_published_time":"2023-04-17T09:00:00+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":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/create-and-use-dictionary-in-c\/#article","isPartOf":{"@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/create-and-use-dictionary-in-c\/"},"author":{"name":"Abdul Mannan","@id":"https:\/\/www.naveedulhaq.com\/#\/schema\/person\/8babf3cd198e47e5c727f67880ea7977"},"headline":"How to Create and Use Dictionary in C#?","datePublished":"2023-04-17T09:00:00+00:00","mainEntityOfPage":{"@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/create-and-use-dictionary-in-c\/"},"wordCount":555,"commentCount":0,"publisher":{"@id":"https:\/\/www.naveedulhaq.com\/#\/schema\/person\/dd6db5980b965fcae41e096d357c65c9"},"image":{"@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/create-and-use-dictionary-in-c\/#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","visual-studio"],"articleSection":[".NET"],"inLanguage":"en-GB","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/create-and-use-dictionary-in-c\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/create-and-use-dictionary-in-c\/","url":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/create-and-use-dictionary-in-c\/","name":"How to Create and Use Dictionary in C#? - Naveed Ul-Haq&#039;s blog","isPartOf":{"@id":"https:\/\/www.naveedulhaq.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/create-and-use-dictionary-in-c\/#primaryimage"},"image":{"@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/create-and-use-dictionary-in-c\/#primaryimage"},"thumbnailUrl":"https:\/\/www.naveedulhaq.com\/wp-content\/uploads\/2021\/11\/240px-.NET_Logo.svg_.png","datePublished":"2023-04-17T09:00:00+00:00","description":"A Dictionary in C# is a collection of key-value pairs, where each key is associated with a unique value providing and easy and quick retrieval.","breadcrumb":{"@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/create-and-use-dictionary-in-c\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/create-and-use-dictionary-in-c\/"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.naveedulhaq.com\/index.php\/dot-net-core\/create-and-use-dictionary-in-c\/#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\/create-and-use-dictionary-in-c\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.naveedulhaq.com\/"},{"@type":"ListItem","position":2,"name":"How to Create and Use Dictionary in C#?"}]},{"@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\/1066","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=1066"}],"version-history":[{"count":0,"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/posts\/1066\/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=1066"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/categories?post=1066"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.naveedulhaq.com\/index.php\/wp-json\/wp\/v2\/tags?post=1066"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}