How to get the length of a multidimensional array in C# ...

文章推薦指數: 80 %
投票人數:10人

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



請為這篇文章評分?