What is a byte[] array?

前端 未结 6 1720
盖世英雄少女心
盖世英雄少女心 2021-02-13 11:49

What is a byte array is in the context of .NET framework?

I am familiar with standard definitions like array and byte and very fam

6条回答
  •  梦毁少年i
    2021-02-13 12:40

    Technically, all of memory is one giant array of bytes (up to 232 addressable bytes in a 32-bit address space). In C# (and C, C++, Java, and many other languages), a byte array is simply a contiguous chunk of memory. Thus a byte[n] array is a block of n bytes.

    Byte arrays typically have no type other than "byte", which is simply an 8-bit data item.

    Byte arrays are generally used for low-level I/O, such as read/write buffers for files and networks, as graphics image buffers, and as "untyped" data streams.

    Addendum

    Bytes are also known as octets, i.e., eight-bit values. Octets are the universal unit for data interchange between practically all computer and information systems in use today.

    Even systems and encodings that use something other than 8-bit values still use octets to read from, write to, and transfer data between those systems. For example, audio CD sound samples are encoded as a stereo pair of signed 16-bit values sampled at 44,100 Hz. When accessed as a flat file (e.g., as a .WAV file) or data stream, though, it appears as a sequence of octets.

    In the context of programming languages, then, such a sound file could be stored in its raw form as a single byte array.

提交回复
热议问题