开发者

C# array byte[].Length property

开发者 https://www.devze.com 2023-03-19 14:18 出处:网络
C# array byte[].Length property. byte[] buffer = new ... When call开发者_运维技巧 int i = buffer.Length; I can see get_Length() in reflector,

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))

0

精彩评论

暂无评论...
验证码 换一张
取 消