A Byte Array with all 0x00 is Equaled to 0x08?

1

I think I encountered something extraordinary strange in VS 2008.

All the array values are 0x00, but why it is displayed 0x00000008 at the start of the variable?

c#
visual-studio-2008
byte
asked on Stack Overflow Apr 9, 2010 by Graviton • edited Jun 25, 2020 by Graviton

5 Answers

9

Visual studio is displaying the size of your array (in items) not the value. You have eight bytes in your array denoted by byte[8] in decimal or byte[0x00000008] as a 32-bit hex value.

Right click the window and select Hexadecimal Display to switch to a decimal view of the values. I find the decimal view more workable when dealing with small integer types and you won't get confused by all the extra hex notation (although it depends on your personal preference).

answered on Stack Overflow Apr 9, 2010 by Ron Warholic • edited Apr 9, 2010 by Ron Warholic
4

That's the length of the array. Eight elements.

answered on Stack Overflow Apr 9, 2010 by Matti Virkkunen
1

Because it's an array of 8 values, 0 through 7

answered on Stack Overflow Apr 9, 2010 by brydgesk
1

8 refers to the length of the byte array.

answered on Stack Overflow Apr 9, 2010 by anonymous
1

This is the length of the array. Notice that in the first column it's listing the indices - there are eight items in the array. (You could think of it as saying that the value of the array is a bytearray with eight items).

answered on Stack Overflow Apr 9, 2010 by Daniel G

User contributions licensed under CC BY-SA 3.0