{"id":68054,"date":"2022-03-21T07:38:02","date_gmt":"2022-03-21T06:38:02","guid":{"rendered":"https:\/\/drafts.code-maze.com\/?p=68054"},"modified":"2022-07-13T12:04:11","modified_gmt":"2022-07-13T10:04:11","slug":"csharp-sum-up-elements-of-an-array","status":"publish","type":"post","link":"https:\/\/code-maze.com\/csharp-sum-up-elements-of-an-array\/","title":{"rendered":"How to Sum Up Elements of an Array in C#"},"content":{"rendered":"<p>A frequent question in .NET interviews is about operations using arrays. In this article, we are going to learn how to sum up elements of an array in C#. After studying the different techniques, we are going to build a performance benchmark and check which one is the best approach to use in each scenario.<\/p>\n<div style=\"padding: 20px; border-left: 5px #dc2323 solid; display: block; margin-bottom: 20px; box-shadow: 1px 1px 5px 0px lightgrey;\">To download the source code for this article, you can visit our <a href=\"https:\/\/github.com\/CodeMazeBlog\/CodeMazeGuides\/tree\/main\/collections-arrays\/SumUpArrayElements\" target=\"_blank\" rel=\"nofollow noopener\">GitHub repository<\/a>.<\/div>\n<p>Let&#8217;s dive in<\/p>\n<h2>Preparing the Environment<\/h2>\n<p>First, let&#8217;s instantiate a new <code>int<\/code> array and fill it with some random elements:<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">private static readonly int[] sourceArray = new int[] { 3, 9, 4, 23, 7, 15, 14, 2, 59, 4 };<\/code><\/p>\n<p>If we are creating a .NET 6 (C# 10) Console Application, we don&#8217;t need to add the <code>System.Linq<\/code> namespace, however, if we are using an earlier version, we should add it:<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">using System.Linq;<\/code><\/p>\n<p>Now that we have our environment ready, let&#8217;s see some approaches.<\/p>\n<h2>Using Iteration to Sum Up Elements of an Array in C#<\/h2>\n<p>We are going to learn two techniques using <a href=\"https:\/\/code-maze.com\/csharp-loops\/\" target=\"_blank\" rel=\"noopener\">the iteration statement<\/a>. Let&#8217;s check it.<\/p>\n<h3>Using For Loop<\/h3>\n<p>Let&#8217;s create a <code>ForLoop<\/code> method to sum all the values in the array:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">public int ForLoop(int[] sourceArray)\r\n{\r\n    var result = 0;\r\n    for (int i = 0; i &lt; sourceArray.Length; i++)\r\n        result += sourceArray[i];\r\n\r\n    return result;\r\n}<\/pre>\n<p>This method receives an array as an input parameter and returns an integer representing the sum of all elements in the array. Inside it, we create a new <code>result<\/code> variable and assign zero to it. Then we iterate through the entire array and increment this variable with the sum of each element of the array.\u00a0<\/p>\n<h3>Using Foreach Loop<\/h3>\n<p>To use the <code>foreach<\/code> loop, we are going to create a new <code>ForeachLoop<\/code> method:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">public int ForeachLoop(int[] sourceArray)\r\n{\r\n    var result = 0;\r\n    foreach (var item in sourceArray)\r\n        result += item;\r\n\r\n    return result;\r\n}<\/pre>\n<p>Similar to the previous technique, we define a <code>result<\/code> variable and, for each element in the array, sum the value and store it to this variable.<\/p>\n<p>There&#8217;s no big difference between using <code>for<\/code> and <code>foreach<\/code> loop to achieve this result. Anyway, it is good to mention and study both methods.<\/p>\n<h2>Using Array Class to Sum the Array Elements<\/h2>\n<p>Another way to achieve this result is using the <code>Array<\/code> class:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">public int ArrayForEach(int[] sourceArray)\r\n{\r\n    var result = 0;\r\n    Array.ForEach(sourceArray, value =&gt; result += value);\r\n\r\n    return result;\r\n}<\/pre>\n<p>In this approach, we define a <code>result<\/code> variable assigning zero as its value. Then we use the <code>ForEach<\/code> method under the <code>Array<\/code> class, to sum all the elements.<\/p>\n<p>The <code>ForEach<\/code> method receives the array we want to iterate as the first parameter, and as a second parameter, it receives an\u00a0 <code>Action<\/code> delegate, which we can execute on each element.<\/p>\n<p>Once the action passes through the entire array, we return the <code>result<\/code> variable.<\/p>\n<h2>Sum the Array Elements With System.Linq<\/h2>\n<p>The <code>System.Linq<\/code> namespace provides us with some classes and methods that allow us to sum every element in the array. Let&#8217;s check some of them.\u00a0<\/p>\n<h3>Enumerable.Sum<\/h3>\n<p>The easiest way to use <code>Linq<\/code> to sum the array elements is using the <code>Sum<\/code> method from the <code>Enumerable<\/code> static class:<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">return Enumerable.Sum(sourceArray);<\/code><\/p>\n<p>Another way to use this same method is:<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">return sourceArray.Sum();<\/code><\/p>\n<p>Note that this is an extension method. That said, both ways will execute the same method. We can check that if we right-click at the <code>Sum<\/code> method in both cases and go to the method definition.<\/p>\n<p>If it is necessary, this method has some overloads that allow us to pass a <code>Func<\/code> to transform each element into a <code>decimal<\/code>, <code>long<\/code>, <code>int<\/code> or <code>float<\/code>.\u00a0<\/p>\n<h3>Enumerable.Aggregate<\/h3>\n<p>Let&#8217;s check how to sum the elements using <code>Aggregate<\/code> method:<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">return sourceArray.Aggregate((total, value) =&gt; total + value);<\/code><\/p>\n<p>This method has a <code>Func<\/code> delegate as a parameter that applies an accumulator over the array.<\/p>\n<p>This <code>Func<\/code> returns an integer representing the sum of those elements. It receives, as input, two variables &#8211; total and current. Respectively, the <code>total<\/code> means the accumulator and the <code>current<\/code> represents each value of the array.<\/p>\n<h2>Benchmark Comparison<\/h2>\n<p>For this article, we are going to implement a benchmark comparison with 1 million elements to see the performance difference between all these 6 approaches:<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">private static readonly int[] _sourceArray = FillElements(1000 * 1000);<\/code><\/p>\n<p>To make it easier to read, instead of writing 1000000, we can use 1000 * 1000.<\/p>\n<p>Now, let&#8217;s define the <code>FillElements<\/code> method that is going to create these random elements:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">private static int[] FillElements(int length)\r\n{\r\n    var randomArray = new int[length];\r\n    for (int i = 0; i &lt; length; i++)\r\n        randomArray[i] = new Random().Next(0, 1000);\r\n\r\n    return randomArray;\r\n}<\/pre>\n<p>After running the benchmark, we can inspect the result:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"raw\">|             Method |       Mean |     Error |    StdDev |     Median |\r\n|------------------- |-----------:|----------:|----------:|-----------:|\r\n|       UsingForLoop |   618.1 us |  12.79 us |  29.38 us |   599.9 us |\r\n|   UsingForeachLoop |   598.7 us |   5.11 us |   4.53 us |   597.5 us |\r\n|  UsingArrayForEach | 2,328.0 us |  42.55 us |  52.26 us | 2,304.8 us |\r\n| UsingEnumerableSum | 5,461.9 us |  77.17 us |  64.44 us | 5,444.3 us |\r\n|      UsingArraySum | 5,428.7 us |  25.61 us |  22.70 us | 5,423.3 us |\r\n|     UsingAggregate | 7,990.9 us | 157.04 us | 244.50 us | 7,864.8 us |<\/pre>\n<p>The fastest method is <code>UsingForeachLoop<\/code> followed by <code>UsingForLoop<\/code> with the difference of 20 us. In both cases, we are not using .NET built-in functions.<\/p>\n<p>When we start using the built-in functions, we make it, at least, 1710 us slower.\u00a0<\/p>\n<p>The slowest method (<code>UsingAggregate<\/code>) is 13 times slower than the fastest method, however, <strong>it is good to mention that we are talking about us (microseconds), which is equivalent to <!--StartFragment -->0.000001 seconds in an array of 1 million elements<\/strong>. So, even though there are differences between these techniques, we can conclude that all execute pretty fast.<\/p>\n<p><!--EndFragment --><\/p>\n<h2>Conclusion<\/h2>\n<p>In this article, we&#8217;ve learned about many methods, to sum up, elements of an array. After a benchmark result, we&#8217;ve seen that using your implementation may be faster than using .NET built-in functions, however, it is up to us to decide which is the technique to use in our code.\u00a0<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A frequent question in .NET interviews is about operations using arrays. In this article, we are going to learn how to sum up elements of an array in C#. After studying the different techniques, we are going to build a performance benchmark and check which one is the best approach to use in each scenario. [&hellip;]<\/p>\n","protected":false},"author":6,"featured_media":62189,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[1057,12],"tags":[1163,1043,946,262,1162,1164,1161],"class_list":["post-68054","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-array","category-csharp","tag-aggregate","tag-array","tag-collections","tag-for","tag-foreach","tag-sum","tag-sum-all-the-array-elements","et-has-post-format-content","et_post_format-et-post-format-standard"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Sum Up Elements of an Array in C# - Code Maze<\/title>\n<meta name=\"description\" content=\"In this article, we are going to explore different techniques to Sum Up Elements of an Array in C# and test them with a benchmark\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/code-maze.com\/csharp-sum-up-elements-of-an-array\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Sum Up Elements of an Array in C# - Code Maze\" \/>\n<meta property=\"og:description\" content=\"In this article, we are going to explore different techniques to Sum Up Elements of an Array in C# and test them with a benchmark\" \/>\n<meta property=\"og:url\" content=\"https:\/\/code-maze.com\/csharp-sum-up-elements-of-an-array\/\" \/>\n<meta property=\"og:site_name\" content=\"Code Maze\" \/>\n<meta property=\"article:published_time\" content=\"2022-03-21T06:38:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-07-13T10:04:11+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/code-maze.com\/wp-content\/uploads\/2021\/12\/social-csharp.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1100\" \/>\n\t<meta property=\"og:image:height\" content=\"620\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Code Maze\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/CodeMazeBlog\" \/>\n<meta name=\"twitter:site\" content=\"@CodeMazeBlog\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Code Maze\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":[\"Article\",\"BlogPosting\"],\"@id\":\"https:\/\/code-maze.com\/csharp-sum-up-elements-of-an-array\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/code-maze.com\/csharp-sum-up-elements-of-an-array\/\"},\"author\":{\"name\":\"Code Maze\",\"@id\":\"https:\/\/code-maze.com\/#\/schema\/person\/09d29b223012c8e94a68ba62861d0b04\"},\"headline\":\"How to Sum Up Elements of an Array in C#\",\"datePublished\":\"2022-03-21T06:38:02+00:00\",\"dateModified\":\"2022-07-13T10:04:11+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/code-maze.com\/csharp-sum-up-elements-of-an-array\/\"},\"wordCount\":764,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/code-maze.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/code-maze.com\/csharp-sum-up-elements-of-an-array\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2021\/12\/social-csharp.png\",\"keywords\":[\"Aggregate\",\"Array\",\"collections\",\"For\",\"Foreach\",\"Sum\",\"Sum all the array elements\"],\"articleSection\":[\"Array\",\"C#\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/code-maze.com\/csharp-sum-up-elements-of-an-array\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/code-maze.com\/csharp-sum-up-elements-of-an-array\/\",\"url\":\"https:\/\/code-maze.com\/csharp-sum-up-elements-of-an-array\/\",\"name\":\"How to Sum Up Elements of an Array in C# - Code Maze\",\"isPartOf\":{\"@id\":\"https:\/\/code-maze.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/code-maze.com\/csharp-sum-up-elements-of-an-array\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/code-maze.com\/csharp-sum-up-elements-of-an-array\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2021\/12\/social-csharp.png\",\"datePublished\":\"2022-03-21T06:38:02+00:00\",\"dateModified\":\"2022-07-13T10:04:11+00:00\",\"description\":\"In this article, we are going to explore different techniques to Sum Up Elements of an Array in C# and test them with a benchmark\",\"breadcrumb\":{\"@id\":\"https:\/\/code-maze.com\/csharp-sum-up-elements-of-an-array\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/code-maze.com\/csharp-sum-up-elements-of-an-array\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/code-maze.com\/csharp-sum-up-elements-of-an-array\/#primaryimage\",\"url\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2021\/12\/social-csharp.png\",\"contentUrl\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2021\/12\/social-csharp.png\",\"width\":1100,\"height\":620,\"caption\":\"C# Development\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/code-maze.com\/csharp-sum-up-elements-of-an-array\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/code-maze.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Sum Up Elements of an Array in C#\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/code-maze.com\/#website\",\"url\":\"https:\/\/code-maze.com\/\",\"name\":\"Code Maze\",\"description\":\"Learn. Code. Succeed.\",\"publisher\":{\"@id\":\"https:\/\/code-maze.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/code-maze.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/code-maze.com\/#organization\",\"name\":\"Code Maze\",\"url\":\"https:\/\/code-maze.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/code-maze.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez.png\",\"contentUrl\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez.png\",\"width\":3511,\"height\":3510,\"caption\":\"Code Maze\"},\"image\":{\"@id\":\"https:\/\/code-maze.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/CodeMazeBlog\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/code-maze.com\/#\/schema\/person\/09d29b223012c8e94a68ba62861d0b04\",\"name\":\"Code Maze\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/code-maze.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez-150x150.png\",\"contentUrl\":\"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez-150x150.png\",\"caption\":\"Code Maze\"},\"description\":\"This is the standard author on the site. Most articles are published by individual authors, with their profiles, but when several authors have contributed, we publish collectively as a part of this profile.\",\"sameAs\":[\"https:\/\/www.linkedin.com\/company\/codemaze\/\",\"https:\/\/x.com\/https:\/\/twitter.com\/CodeMazeBlog\"],\"url\":\"https:\/\/code-maze.com\/author\/codemazecontributor\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Sum Up Elements of an Array in C# - Code Maze","description":"In this article, we are going to explore different techniques to Sum Up Elements of an Array in C# and test them with a benchmark","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:\/\/code-maze.com\/csharp-sum-up-elements-of-an-array\/","og_locale":"en_US","og_type":"article","og_title":"How to Sum Up Elements of an Array in C# - Code Maze","og_description":"In this article, we are going to explore different techniques to Sum Up Elements of an Array in C# and test them with a benchmark","og_url":"https:\/\/code-maze.com\/csharp-sum-up-elements-of-an-array\/","og_site_name":"Code Maze","article_published_time":"2022-03-21T06:38:02+00:00","article_modified_time":"2022-07-13T10:04:11+00:00","og_image":[{"width":1100,"height":620,"url":"https:\/\/code-maze.com\/wp-content\/uploads\/2021\/12\/social-csharp.png","type":"image\/png"}],"author":"Code Maze","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/CodeMazeBlog","twitter_site":"@CodeMazeBlog","twitter_misc":{"Written by":"Code Maze","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["Article","BlogPosting"],"@id":"https:\/\/code-maze.com\/csharp-sum-up-elements-of-an-array\/#article","isPartOf":{"@id":"https:\/\/code-maze.com\/csharp-sum-up-elements-of-an-array\/"},"author":{"name":"Code Maze","@id":"https:\/\/code-maze.com\/#\/schema\/person\/09d29b223012c8e94a68ba62861d0b04"},"headline":"How to Sum Up Elements of an Array in C#","datePublished":"2022-03-21T06:38:02+00:00","dateModified":"2022-07-13T10:04:11+00:00","mainEntityOfPage":{"@id":"https:\/\/code-maze.com\/csharp-sum-up-elements-of-an-array\/"},"wordCount":764,"commentCount":0,"publisher":{"@id":"https:\/\/code-maze.com\/#organization"},"image":{"@id":"https:\/\/code-maze.com\/csharp-sum-up-elements-of-an-array\/#primaryimage"},"thumbnailUrl":"https:\/\/code-maze.com\/wp-content\/uploads\/2021\/12\/social-csharp.png","keywords":["Aggregate","Array","collections","For","Foreach","Sum","Sum all the array elements"],"articleSection":["Array","C#"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/code-maze.com\/csharp-sum-up-elements-of-an-array\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/code-maze.com\/csharp-sum-up-elements-of-an-array\/","url":"https:\/\/code-maze.com\/csharp-sum-up-elements-of-an-array\/","name":"How to Sum Up Elements of an Array in C# - Code Maze","isPartOf":{"@id":"https:\/\/code-maze.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/code-maze.com\/csharp-sum-up-elements-of-an-array\/#primaryimage"},"image":{"@id":"https:\/\/code-maze.com\/csharp-sum-up-elements-of-an-array\/#primaryimage"},"thumbnailUrl":"https:\/\/code-maze.com\/wp-content\/uploads\/2021\/12\/social-csharp.png","datePublished":"2022-03-21T06:38:02+00:00","dateModified":"2022-07-13T10:04:11+00:00","description":"In this article, we are going to explore different techniques to Sum Up Elements of an Array in C# and test them with a benchmark","breadcrumb":{"@id":"https:\/\/code-maze.com\/csharp-sum-up-elements-of-an-array\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/code-maze.com\/csharp-sum-up-elements-of-an-array\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/code-maze.com\/csharp-sum-up-elements-of-an-array\/#primaryimage","url":"https:\/\/code-maze.com\/wp-content\/uploads\/2021\/12\/social-csharp.png","contentUrl":"https:\/\/code-maze.com\/wp-content\/uploads\/2021\/12\/social-csharp.png","width":1100,"height":620,"caption":"C# Development"},{"@type":"BreadcrumbList","@id":"https:\/\/code-maze.com\/csharp-sum-up-elements-of-an-array\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/code-maze.com\/"},{"@type":"ListItem","position":2,"name":"How to Sum Up Elements of an Array in C#"}]},{"@type":"WebSite","@id":"https:\/\/code-maze.com\/#website","url":"https:\/\/code-maze.com\/","name":"Code Maze","description":"Learn. Code. Succeed.","publisher":{"@id":"https:\/\/code-maze.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/code-maze.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/code-maze.com\/#organization","name":"Code Maze","url":"https:\/\/code-maze.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/code-maze.com\/#\/schema\/logo\/image\/","url":"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez.png","contentUrl":"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez.png","width":3511,"height":3510,"caption":"Code Maze"},"image":{"@id":"https:\/\/code-maze.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/CodeMazeBlog"]},{"@type":"Person","@id":"https:\/\/code-maze.com\/#\/schema\/person\/09d29b223012c8e94a68ba62861d0b04","name":"Code Maze","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/code-maze.com\/#\/schema\/person\/image\/","url":"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez-150x150.png","contentUrl":"https:\/\/code-maze.com\/wp-content\/uploads\/2020\/01\/Code-Maze-Only-Logo-Transparent-HRez-150x150.png","caption":"Code Maze"},"description":"This is the standard author on the site. Most articles are published by individual authors, with their profiles, but when several authors have contributed, we publish collectively as a part of this profile.","sameAs":["https:\/\/www.linkedin.com\/company\/codemaze\/","https:\/\/x.com\/https:\/\/twitter.com\/CodeMazeBlog"],"url":"https:\/\/code-maze.com\/author\/codemazecontributor\/"}]}},"_links":{"self":[{"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/posts\/68054","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/comments?post=68054"}],"version-history":[{"count":5,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/posts\/68054\/revisions"}],"predecessor-version":[{"id":68399,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/posts\/68054\/revisions\/68399"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/media\/62189"}],"wp:attachment":[{"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/media?parent=68054"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/categories?post=68054"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/code-maze.com\/wp-json\/wp\/v2\/tags?post=68054"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}