# BufferSlice Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.pooledbuffer.bufferslice/)

## CopyTo(Span&lt;byte&gt;) {#copyto-system-span-byte-a8e5bb6f}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.pooledbuffer.bufferslice/methods/copyto-system-span-byte-a8e5bb6f/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/PooledBuffer.cs)

```csharp
public int CopyTo(Span<byte> output)
```

Copies the contents of this writer to a span.

### Parameters

- `output` (`Span<byte>`)

## CopyTo(PooledBuffer) {#copyto-ref-orleans-serialization-buffers-pooledbuffer-eada3d2e}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.pooledbuffer.bufferslice/methods/copyto-ref-orleans-serialization-buffers-pooledbuffer-eada3d2e/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/PooledBuffer.cs)

```csharp
public void CopyTo(ref PooledBuffer output)
```

Copies the contents of this writer to a pooled buffer.

### Parameters

- `output` (`PooledBuffer`)

## CopyTo(TBufferWriter) {#copyto-1-ref-tbufferwriter-c1e76459}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.pooledbuffer.bufferslice/methods/copyto-1-ref-tbufferwriter-c1e76459/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/PooledBuffer.cs)

```csharp
public void CopyTo<TBufferWriter>(ref TBufferWriter output)
```

Copies the contents of this writer to a buffer writer.

### Parameters

- `output` (`TBufferWriter`)

## GetEnumerator {#getenumerator-0103c335}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.pooledbuffer.bufferslice/methods/getenumerator-0103c335/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/PooledBuffer.cs#L614)

```csharp
public SpanEnumerator GetEnumerator()
```

Returns an enumerator which can be used to enumerate the data referenced by this instance.

### Returns

An enumerator for the data contained in this instance.

## Slice(int) {#slice-int-7fec6e93}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.pooledbuffer.bufferslice/methods/slice-int-7fec6e93/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/PooledBuffer.cs#L556)

```csharp
public BufferSlice Slice(int offset)
```

Forms a slice out of this instance, beginning at the specified offset into this slice.

### Parameters

- `offset` (`int`): The offset into this slice where the newly formed slice will begin.

### Returns

A slice instance.

## Slice(int, int) {#slice-int-int-544c7d0a}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.pooledbuffer.bufferslice/methods/slice-int-int-544c7d0a/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/PooledBuffer.cs#L564)

```csharp
public BufferSlice Slice(int offset, int length)
```

Forms a slice out of this instance, beginning at the specified offset into this slice and having the specified length.

### Parameters

- `offset` (`int`): The offset into this slice where the newly formed slice will begin.
- `length` (`int`): The length of the new slice.

### Returns

A slice instance.

## ToArray {#toarray-31a64349}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.pooledbuffer.bufferslice/methods/toarray-31a64349/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/PooledBuffer.cs#L605-L607)

```csharp
public byte[] ToArray()
```

Returns the data which has been written as an array.

### Returns

The data which has been written.
