.NET阵 - 之间和QUOT差异,长度和QUOT;," COUNT()"和"排名" [英] .net array - difference between "Length", "Count()" and "Rank"
问题描述
什么是之间的长度的区别,伯爵()和等级对.NET阵列?
What's the difference between "Length", "Count()" and "Rank" for .net array?
推荐答案
长度
是数组对象的属性和使用它是最有效的方法来确定的数数组中的元素( Array.Length在MSDN文档)
Length
is the property of array object and using it is the most effective way to determine the count of elements in the array (Array.Length in MSDN documentation)
计数()
是确实有效的同一个LINQ扩展方法。它适用于数组,因为数组是枚举对象。这是preferred使用长度
,因为计数()
很可能会更加昂贵(见的this问题进一步讨论和的指望仅供参考MSDN文档)
Count()
is a LINQ extension method that does effectively the same. It applies to arrays because arrays are enumerable objects. It's preferred to use Length
because Count()
is likely to be more expensive (see this question for further discussion and MSDN documentation on Count for reference)
排名
是一个返回维数(不同的东西完全)的财产。当你声明数组 INT [,] myArray的=新INT [5,10];
的排名
它会是2,但它会举行,共50个元素( MSDN上排名物业 )。
Rank
is the property that returns the number of dimensions (different thing entirely). When you declare an array int[,] myArray = new int[5,10];
the Rank
of it will be 2 but it will hold a total of 50 elements (MSDN on Rank property).
编辑:感谢Kornelije Petak的相关MSDN链接
thanks to Kornelije Petak for relevant MSDN links.
这篇关于.NET阵 - 之间和QUOT差异,长度和QUOT;," COUNT()"和"排名"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!