C# array byte[].Length property
C# array byte[].Length property.
byte[] buffer = new ...
When call开发者_运维技巧 int i = buffer.Length; I can see get_Length() in reflector,
What happens? Does it calculate actual length or just takes value (like property) ???
byte[].Length
will tell you the total number of elements in the array, so retrieving this property has a complexity of O(1)
.
Arrays are fixed-length; the Length
property returns an internal field in the array.
(It's O(1)
, not O(n)
)
精彩评论