# ReadBytes

> Read and copy data into the given NativeArray of bytes. An error will be logged if not enough bytes are available to fill the array, and DataStreamReader.HasFailedReads will then be true.

## Definition

* **Type:** Method
* **Namespace:** [Unity.Collections](/engine/6000.7/script-reference/unity/collections.md)
* **Assembly:** UnityEngine.ManagedKernelModule

## ReadBytes(NativeArray\<byte>)

Read and copy data into the given NativeArray of bytes. An error will be logged if not enough bytes are available to fill the array, and [DataStreamReader.HasFailedReads](/engine/6000.7/script-reference/unity/collections/datastreamreader/hasfailedreads.md) will then be true.

```csharp
public void ReadBytes(NativeArray<byte> array)
```

### Parameters

**** (\[NativeArray\<byte>]\(/engine/6000.7/script-reference/unity/collections/nativearray1)): Array to copy data into.

## ReadBytes(Span\<byte>)

Read and copy data into the given `Span` of bytes. An error will be logged if not enough bytes are available to fill the array, and [DataStreamReader.HasFailedReads](/engine/6000.7/script-reference/unity/collections/datastreamreader/hasfailedreads.md) will then be true.

```csharp
public void ReadBytes(Span<byte> span)
```

### Parameters

**** (\[Span\<byte>]\(https\://learn.microsoft.com/dotnet/api/system.span-1)): Span to copy data into.
