{"id":549,"date":"2022-05-10T15:07:15","date_gmt":"2022-05-10T14:07:15","guid":{"rendered":"https:\/\/ibex.tech\/csharp\/?p=549"},"modified":"2024-06-20T11:50:04","modified_gmt":"2024-06-20T10:50:04","slug":"multidimension-arrays","status":"publish","type":"post","link":"https:\/\/ibex.tech\/csharp\/c-sharp\/memory\/arrays\/multidimension-arrays","title":{"rendered":"Multidimensional arrays"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">2 Dimensional Arrays<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\tstring&#91;,] My2DimensionalArray;\n\tMy2DimensionalArray = new string&#91;4, 10];<\/code><\/pre>\n\n\n\n<p>Or as a jagged array<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\tstring&#91;]&#91;] My2DimensionalArray;\n\tMy2DimensionalArray = new string&#91;2]&#91;];\n\tMy2DimensionalArray&#91;0] = new string&#91;20];\n\tMy2DimensionalArray&#91;1] = new string&#91;20];<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Getting length of each part of an array <\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\tint&#91;,] MyArray = new int&#91;5, 10];\n\tint Length = MyArray.GetLength(0); \/\/ Gets 5\n\tint Length = MyArray.GetLength(1); \/\/ Gets 10\n\n\t\/\/N.B. GetLength(#) # is not the Index!<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Example usage<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>\tint&#91;,] MyArray = new int&#91;5, 10];\n\tint = Index;\n\tint = Index1;\n\n\tfor (Index = 0; Index &lt; MyArray.GetLength(0); Index++)\n\t{\n\t\tfor (Index1 = 0; Index1 &lt; MyArray.GetLength(1); Index1++)\n\t\t\tint a = MyArray&#91;Index,Index1];\n\t}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>2 Dimensional Arrays Or as a jagged array Getting length of each part of an array Example usage<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-549","post","type-post","status-publish","format-standard","hentry","category-arrays"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/549","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/comments?post=549"}],"version-history":[{"count":4,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/549\/revisions"}],"predecessor-version":[{"id":1338,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/549\/revisions\/1338"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/media?parent=549"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/categories?post=549"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/tags?post=549"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}