Sign up ×

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

I am familiar with standard definitions like array and byte and very familiar with electronic engineering concepts such as Byte. But I fail to connect it in terms of computer science concepts. I see it used everywhere, and I use it with out really understanding it deeply.

share|improve this question
is byte array is somehow different from any other array? why do you explicitly ask about byte array? – Andrey Jun 21 '10 at 22:52
I find it hard to understand how you could say you are familiar with the standard definitions of "array" and "byte" and yet not understand what the term "byte array" would mean. What about it is confusing to you? – Daniel Pryden Jun 21 '10 at 23:10

6 Answers 6

up vote 11 down vote accepted

In .NET, a byte is basically a number from 0 to 255 (the numbers that can be represented by eight bits).

So, a byte array is just an array of the numbers 0 - 255.

At a lower level, an array is a contiguous block of memory, and a byte array is just a representation of that memory in 8-bit chunks.

share|improve this answer
Thanks... I wrote the following simple applet and it works great... static void Main(string[] args) { byte[] bytearray = new byte[] { 0, 1, 2, 3, 254, 255 }; foreach (byte b in bytearray) { Console.WriteLine("{0}",b.ToString()); } Console.ReadLine(); } – dotnet-practitioner Jun 21 '10 at 22:48

A byte[] array is simply an array of raw data. For example, a file of size 2000 bytes can be loaded into a byte[] array of 2000 elements.

share|improve this answer

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.


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.

share|improve this answer

A byte is 8 bits, and an array of byte, is an array of bytes... It really is that simple.

The thing to keep in mind is that char and byte are different. In old C style, a char and byte were basically the same thing. In .NET, characters are Unicode and can be anywhere from 8-32 bits per character. This is where encoding comes into play. You can convert a string to a byte array, and you can convert a byte array into a string by using the Encoding class.

share|improve this answer

It's an array of byte. It's binary data - unstructured (in terms of the language at that point in time - different than meaningless!) data which can be arbitrarily long.

Think of loading a picture from a file. You would read the file into a byte[] before working with the image.

share|improve this answer

Byte Array: An array which only has elements of Byte type. Byte: Positive integer number between 0 and 255, closed intervallum. A and B are two bytes.

If C = A + B, then, mathematically, C = (A + B) modulo 256 If C = A - B, then, mathematically, C = (A - B) modulo 256

So, you could consider (and sometimes use) your Byte Array of n elements as a number in the radix of 256, with n digits.

share|improve this answer

Your Answer


