Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a byte[] array?

Tags:

arrays

.net

byte

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.

like image 283
dotnet-practitioner Avatar asked Jun 21 '10 22:06

dotnet-practitioner


People also ask

What is an byte array?

bytearray() method returns a bytearray object which is an array of given bytes. It gives a mutable sequence of integers in the range 0 <= x < 256. Syntax: bytearray(source, encoding, errors)

What is a byte [] in Java?

A byte in Java is 8 bits. It is a primitive data type, meaning it comes packaged with Java. Bytes can hold values from -128 to 127. No special tasks are needed to use it; simply declare a byte variable and you are off to the races.

What does [] byte mean in go?

A byte in Go is an unsigned 8-bit integer. It has type uint8 . A byte has a limit of 0 – 255 in numerical range. It can represent an ASCII character.

What is a byte [] in C#?

In C#, Byte Struct is used to represent 8-bit unsigned integers. The Byte is an immutable value type and the range of Byte is from 0 to 255. This class allows you to create Byte data types and you can perform mathematical and bitwise operations on them like addition, subtraction, multiplication, division, XOR, AND etc.


2 Answers

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.

like image 174
jjnguy Avatar answered Oct 01 '22 01:10

jjnguy


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.

like image 34
spoulson Avatar answered Sep 30 '22 23:09

spoulson