# Writer&lt;TBufferWriter&gt; Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.writer-1/)

## AdvanceSpan(int) {#advancespan-int-76ada510}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.writer-1/methods/advancespan-int-76ada510/)

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

```csharp
public void AdvanceSpan(int length)
```

Advance the write position in the current span.

### Parameters

- `length` (`int`): The number of bytes to advance wirte position by.

## Allocate(int) {#allocate-int-17f840a5}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.writer-1/methods/allocate-int-17f840a5/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/Writer.cs#L275-L283)

```csharp
public void Allocate(int sizeHint)
```

Allocates buffer space for the specified number of bytes.

### Parameters

- `sizeHint` (`int`): The number of bytes to reserve.

## Commit {#commit-a7025abe}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.writer-1/methods/commit-a7025abe/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/Writer.cs#L235-L243)

```csharp
public void Commit()
```

Commit the currently written buffers.

## Dispose {#dispose-0fbaa112}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.writer-1/methods/dispose-0fbaa112/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/Writer.cs#L187-L198)

```csharp
public void Dispose()
```

## EnsureContiguous(int) {#ensurecontiguous-int-494953cc}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.writer-1/methods/ensurecontiguous-int-494953cc/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/Writer.cs#L253-L265)

```csharp
public void EnsureContiguous(int length)
```

Ensures that there are at least `length` contiguous bytes available to be written.

### Parameters

- `length` (`int`): The number of contiguous bytes to ensure.

## Write(ReadOnlySpan&lt;byte&gt;) {#write-system-readonlyspan-byte-32e5a397}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.writer-1/methods/write-system-readonlyspan-byte-32e5a397/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/Writer.cs#L293-L303)

```csharp
public void Write(scoped ReadOnlySpan<byte> value)
```

Writes the specified value.

### Parameters

- `value` (`ReadOnlySpan<byte>`): The value.

## WriteByte(byte) {#writebyte-byte-3d589eab}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.writer-1/methods/writebyte-byte-3d589eab/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/Writer.cs#L335-L346)

```csharp
public void WriteByte(byte value)
```

Writes the provided `System.Byte` to the output buffer.

### Parameters

- `value` (`byte`): The value.

## WriteEndBase {#writeendbase-7591b082}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.writer-1/methods/writeendbase-7591b082/)

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

```csharp
public void WriteEndBase()
```

Writes the end base tag.

## WriteEndObject {#writeendobject-ae1e0114}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.writer-1/methods/writeendobject-ae1e0114/)

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

```csharp
public void WriteEndObject()
```

Writes the end object tag.

## WriteFieldHeader(uint, Type, Type, WireType) {#writefieldheader-uint-system-type-system-type-orleans-serialization-wireprotocol-51f65f0e}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.writer-1/methods/writefieldheader-uint-system-type-system-type-orleans-serialization-wireprotocol-51f65f0e/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/Writer.FieldHeader.cs#L22-L56)

```csharp
public void WriteFieldHeader(uint fieldId, Type expectedType, Type actualType, WireType wireType)
```

Writes the field header.

### Parameters

- `fieldId` (`uint`): The field identifier.
- `expectedType` (`Type`): The expected type.
- `actualType` (`Type`): The actual type.
- `wireType` (`WireType`): The wire type.

## WriteFieldHeaderExpected(uint, WireType) {#writefieldheaderexpected-uint-orleans-serialization-wireprotocol-wiretype-c61b04e4}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.writer-1/methods/writefieldheaderexpected-uint-orleans-serialization-wireprotocol-wiretype-c61b04e4/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/Writer.FieldHeader.cs#L76-L81)

```csharp
public void WriteFieldHeaderExpected(uint fieldId, WireType wireType)
```

Writes an expected field header value.

### Parameters

- `fieldId` (`uint`): The field identifier.
- `wireType` (`WireType`): The wire type of the field.

## WriteInt32(int) {#writeint32-int-b64bafe0}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.writer-1/methods/writeint32-int-b64bafe0/)

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

```csharp
public void WriteInt32(int value)
```

Writes the provided `System.Int32` to the output buffer.

### Parameters

- `value` (`int`): The value.

## WriteInt64(long) {#writeint64-long-57206b54}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.writer-1/methods/writeint64-long-57206b54/)

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

```csharp
public void WriteInt64(long value)
```

Writes the provided `System.Int64` to the output buffer.

### Parameters

- `value` (`long`): The value.

## WriteStartObject(uint, Type, Type) {#writestartobject-uint-system-type-system-type-4ba2d8b4}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.writer-1/methods/writestartobject-uint-system-type-system-type-4ba2d8b4/)

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

```csharp
public void WriteStartObject(uint fieldId, Type expectedType, Type actualType)
```

Writes the start object tag.

### Parameters

- `fieldId` (`uint`): The field identifier.
- `expectedType` (`Type`): The expected type.
- `actualType` (`Type`): The actual type.

## WriteUInt32(uint) {#writeuint32-uint-9c4e5456}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.writer-1/methods/writeuint32-uint-9c4e5456/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/Writer.cs#L377-L389)

```csharp
public void WriteUInt32(uint value)
```

Writes the provided `System.UInt32` to the output buffer.

### Parameters

- `value` (`uint`): The value.

## WriteUInt64(ulong) {#writeuint64-ulong-0427e584}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.writer-1/methods/writeuint64-ulong-0427e584/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/Writer.cs#L406-L418)

```csharp
public void WriteUInt64(ulong value)
```

Writes the provided `System.UInt64` to the output buffer.

### Parameters

- `value` (`ulong`): The value.

## WriteVarInt16(short) {#writevarint16-short-82894740}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.writer-1/methods/writevarint16-short-82894740/)

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

```csharp
public void WriteVarInt16(short value)
```

Writes a variable-width `System.Int16`.

### Parameters

- `value` (`short`): The value.

## WriteVarInt32(int) {#writevarint32-int-4e96d417}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.writer-1/methods/writevarint32-int-4e96d417/)

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

```csharp
public void WriteVarInt32(int value)
```

Writes a variable-width `System.Int32`.

### Parameters

- `value` (`int`): The value.

## WriteVarInt64(long) {#writevarint64-long-00ece8d1}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.writer-1/methods/writevarint64-long-00ece8d1/)

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

```csharp
public void WriteVarInt64(long value)
```

Writes a variable-width `System.Int64`.

### Parameters

- `value` (`long`): The value.

## WriteVarInt8(sbyte) {#writevarint8-sbyte-c1e71fc4}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.writer-1/methods/writevarint8-sbyte-c1e71fc4/)

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

```csharp
public void WriteVarInt8(sbyte value)
```

Writes a variable-width `System.SByte`.

### Parameters

- `value` (`sbyte`): The value.

## WriteVarUInt16(ushort) {#writevaruint16-ushort-f08b9b9a}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.writer-1/methods/writevaruint16-ushort-f08b9b9a/)

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

```csharp
public void WriteVarUInt16(ushort value)
```

Writes a variable-width `System.UInt16`.

### Parameters

- `value` (`ushort`): The value.

## WriteVarUInt32(uint) {#writevaruint32-uint-47b8694d}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.writer-1/methods/writevaruint32-uint-47b8694d/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/Writer.cs#L480-L495)

```csharp
public void WriteVarUInt32(uint value)
```

Writes the provided `System.UInt32` to the output buffer as a variable-width integer.

### Parameters

- `value` (`uint`): The value.

## WriteVarUInt64(ulong) {#writevaruint64-ulong-f1d21711}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.writer-1/methods/writevaruint64-ulong-f1d21711/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Buffers/Writer.cs#L539-L562)

```csharp
public void WriteVarUInt64(ulong value)
```

Writes the provided `System.UInt64` to the output buffer as a variable-width integer.

### Parameters

- `value` (`ulong`): The value.

## WriteVarUInt8(byte) {#writevaruint8-byte-88685c02}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.buffers.writer-1/methods/writevaruint8-byte-88685c02/)

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

```csharp
public void WriteVarUInt8(byte value)
```

Writes a variable-width `System.Byte`.

### Parameters

- `value` (`byte`): The value.
