# BeginForEachIndex(int)

> Readies this reader to read a particular buffer of the stream.

## Definition

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

```csharp
public int BeginForEachIndex(int foreachIndex)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the buffer to read.

### Returns

| Type                                                       | Description                                               |
| ---------------------------------------------------------- | --------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The number of remaining elements to read from the buffer. |

### Remarks

Must be called before using this reader. For an individual reader, call this method only once.

When done using this reader, you must call [UnsafeStream.Reader.EndForEachIndex](/engine/6000.7/script-reference/unity/collections/lowlevel/unsafe/unsafestream/reader/endforeachindex.md).
