是什么Array.GetLength()和Array.Length之间的区别? [英] What is the difference between Array.GetLength() and Array.Length?

查看:508
本文介绍了是什么Array.GetLength()和Array.Length之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你如何使用 Array.GetLength 函数在C#?

How do you use the Array.GetLength function in C#?

是什么长度属性和对GetLength 函数之间的区别?

What is the difference between the Length property and the GetLength function?

推荐答案

对GetLength 需要,指定要查询并返回其长度数组的维整数。 长度属性返回的项目在数组总数:

GetLength takes an integer that specifies the dimension of the array that you're querying and returns its length. Length property returns the total number of items in an array:

int[,,] a = new int[10,11,12];
Console.WriteLine(a.Length);           // 1320
Console.WriteLine(a.GetLength(0));     // 10
Console.WriteLine(a.GetLength(1));     // 11
Console.WriteLine(a.GetLength(2));     // 12

这篇关于是什么Array.GetLength()和Array.Length之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆