# IRehydrationContext Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.runtime.irehydrationcontext/)

## TryGetBytes(string, ReadOnlySequence&lt;byte&gt;) {#trygetbytes-string-out-system-buffers-readonlysequence-byte-e895d322}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.runtime.irehydrationcontext/methods/trygetbytes-string-out-system-buffers-readonlysequence-byte-e895d322/)

```csharp
public abstract bool TryGetBytes(string key, out ReadOnlySequence<byte> value)
```

Tries to get a sequence of bytes from the rehydration context, associated with the provided key.

### Parameters

- `key` (`string`): The key.
- `value` (`ReadOnlySequence<byte>`): The value, if present.

### Returns

`true` if the key exists in the context, otherwise `false`.

## TryGetValue(string, T?) {#trygetvalue-1-string-out-t-nullable-ddee708e}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.runtime.irehydrationcontext/methods/trygetvalue-1-string-out-t-nullable-ddee708e/)

```csharp
public abstract bool TryGetValue<T>(string key, out T? value)
```

Tries to get a value from the rehydration context, associated with the provided key, deserializing it using [Serializer](/orleans/docs/api/csharp/microsoft.orleans.serialization/orleans.serialization.serializer/). If a serializer is found for the value, and the key is present, then the value is deserialized and the method returns `true`. If no serializer exists or the key has already been added, then the value is not added and the method returns `false`.

### Parameters

- `key` (`string`): The key.
- `value` (`T?`): The value, if present.

### Returns

`true` if the key exists in the context, otherwise `false`.
