# KeyValuePairCodec&lt;TKey, TValue&gt;.WriteField(Writer&lt;TBufferWriter&gt;, uint, Type, KeyValuePair&lt;TKey, TValue&gt;)

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.codecs.keyvaluepaircodec-2/) | [Methods](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.codecs.keyvaluepaircodec-2/methods/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Serialization/Codecs/KeyValuePairCodec.cs#L42-L49)

```csharp
public void KeyValuePairCodec<TKey, WriteField<TBufferWriter>(ref Writer<TBufferWriter> writer, uint fieldIdDelta, Type expectedType, KeyValuePair<TKey, TValue> value)
```

Writes a field.

### Parameters

- `writer` (`Writer<TBufferWriter>`): The writer.
- `fieldIdDelta` (`uint`): The field identifier delta.
- `expectedType` (`Type`): The expected type.
- `value` (`KeyValuePair<TKey, TValue>`): The value.
