亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

關于二維數組GetLength的用法

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;


namespace ConsoleApp8

{

? ? class Program

? ? {

? ? ? ? static void Main(string[] args)

? ? ? ? {

? ? ? ? ? ? int[,] text = new int[,]{ { 1, 2, 3 }, { 1, 2, 3 } };

? ? ? ? ? ? Console.Write(text.GetLength(1));


? ? ? ? }

括號里是0輸出2

括號里為1輸出3

求解


正在回答

2 回答

對于二維數組的GetLength方法的參數,為0時獲取的是二維數組內一位數組的個數,也就是行數,為1時獲取的是列的個數,也就是每個一維數組內元素個數,類似我這個

?int[,] text = { { 1, 2, 3, 4 }, { 1, 2, 3 ,4},{ 2,6,9,10} };

?Console.Write(text.GetLength(0));? ? 輸出3

?Console.Write(text.GetLength(1));? ? 輸出4

昨天才開始看C#,...多包涵


3 回復 有任何疑惑可以回復我~

GetLength(0)是計算二維數組的行數,GetLength(1)是計算二維數組的列數

1 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

關于二維數組GetLength的用法

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號