# ObjectSerializer.Serialize(object?, Stream, SerializerSession, Type, int)

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.objectserializer/) | [Methods](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.objectserializer/methods/)

[Source](https://github.com/dotnet/orleans/blob/b7a9e3e1c9c54b3cec3a467c5734bf7744541bcf/src/Orleans.Serialization/Serializer.cs#L1501-L1520)

```csharp
public void Serialize(object? value, Stream destination, SerializerSession session, Type type, int sizeHint = 0)
```

Serializes the provided `value` into `destination`.

### Parameters

- `value` (`object?`): The value to serialize.
- `destination` (`Stream`): The destination where serialized data will be written.
- `session` (`SerializerSession`): The serializer session.
- `type` (`Type`): The expected type of the value.
- `sizeHint` (`int`): The estimated upper bound for the length of the serialized data.
