简体   繁体   English

C# 数组 byte[].Length 属性

[英]C# array byte[].Length property

C# array byte[].Length property. C# 数组字节[].Length 属性。

byte[] buffer = new...字节 [] 缓冲区 = 新...

When call int i = buffer.Length;当调用 int i = buffer.Length; I can see get_Length() in reflector,我可以在反射器中看到 get_Length(),

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) . byte[].Length将告诉您数组中的元素总数,因此检索此属性的复杂性为O(1)

Arrays are fixed-length; Arrays 是定长的; the Length property returns an internal field in the array. Length属性返回数组中的一个内部字段。
(It's O(1) , not O(n) ) (这是O(1) ,而不是O(n)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM