How to get the length of a multidimensional array in C# ...
文章推薦指數: 80 %
To get the length of a multidimensional (row/column) array, we can use the Array.GetLength() method in C#. Let's say you have a multidimensional ... Togetthelengthofamultidimensional(row/column)array,wecanusetheArray.GetLength()methodinC#. Let’ssayyouhaveamultidimensionalarraylikethis. int[,,]numList=newint[2,3,5]; Yougetthelengthofanarrayforthefirstdimensionlikethis: numList.GetLength(0);//2 Similarly,youcangetthesecondandthirddimensionssize: //seconddimensionsize numList.GetLength(1);//3 //thirddimensionsize numList.GetLength(2);//5 Note:Dimensionsarezero-based(0)indexing. Ifyouwanttoknowthenumberofdimensionsinamultidimensionalarray,youcanusetheRankproperty. Example: int[,,]numList=newint[2,3,5]; console.WriteLine(numList.Rank);//3Share:GetmylatesttutorialsEmailRelatedtutorialsHowtogetfirstfivecharactersfromastringinC#HowtoconverttheStringtoaDoubleinC#HowtogetthelastnumberfromaStringinC#Howtodeterminethelength(size)ofanarrayinC#HowtogetfirstcharacterofastringinC#Share:CssTutorials&DemosHowrotateanimagecontinuouslyinCSSInthisdemo,wearegoingtolearnabouthowtorotateanimagecontinuouslyusingthecssanimations.HowtocreateaInstagramloginPageInthisdemo,iwillshowyouhowtocreateainstagramloginpageusinghtmlandcss.HowtocreateapulseanimationinCSSInthisdemo,iwillshowyouhowtocreateapulseanimationusingcss.CreatingasnowfallanimationusingcssandJavaScriptInthisdemo,iwillshowyouhowtocreateasnowfallanimationusingcssandJavaScript.TopUdemyCoursesJavaScript-TheCompleteGuide2021(Beginner+Advanced)64,026studentsenrolled52hoursofvideocontentViewCourseReact-TheCompleteGuide(inclHooks,ReactRouter,Redux)284,472studentsenrolled40hoursofvideocontentViewCourseVue-TheCompleteGuide(w/Router,Vuex,CompositionAPI)152,857studentsenrolled48.5hoursofvideocontentViewCourse
延伸文章資訊
- 1How to find the length of an Array in C# - GeeksforGeeks
Array.Length Property is used to get the total number of elements in all the dimensions of the Ar...
- 2Find length of an array in C# | Techie Delight
Alternatively, you can use the Array.GetLength() method to get the length of a single-dimensional...
- 3How to get the length of a multidimensional array in C# ...
To get the length of a multidimensional (row/column) array, we can use the Array.GetLength() meth...
- 4Get the Length of an Array in C# | Delft Stack
- 5C# Array.Length屬性代碼示例- 純淨天空
C# Array.Length屬性代碼示例,System.Array.Length用法.