# Get as Byte Stream

At times, we don't always need to save to persistent or local storage. We many need to pass the serialized data to a remote server over network. In that case we provide couple of methods to achieve this task.

{% hint style="info" %}
You can use these methods to save your data to cloud and sync across all your devices.
{% endhint %}

#### SerializeToByteArray

This serializes any data passed and returns a byte array.

### Examples

#### Save Int

{% tabs %}
{% tab title="Generic Usage" %}

```csharp
byte[] data = SerializationManager.SerializeToByteArray<int>(123);
```

{% endtab %}

{% tab title="Direct Usage" %}

```csharp
byte[] data = SerializationManager.SerializeToByteArray(123);
```

{% endtab %}
{% endtabs %}

#### Save Float

{% tabs %}
{% tab title="Generic Usage" %}

```csharp
byte[] data = SerializationManager.SerializeToByteArray<float>(111.11f);
```

{% endtab %}

{% tab title="Direct Usage" %}

```
byte[] data = SerializationManager.SerializeToByteArray(111.11f);
```

{% endtab %}
{% endtabs %}

#### Save Double

```csharp
byte[] data = SerializationManager.SerializeToByteArray<double>(129.0);
```

#### Save String

{% tabs %}
{% tab title="Generic Usage" %}

```csharp
byte[] data = SerializationManager.SerializeToByteArray<string>("string value");
```

{% endtab %}

{% tab title="Direct Usage" %}

```csharp
byte[] data = SerializationManager.SerializeToByteArray("string value");
```

{% endtab %}
{% endtabs %}

#### Save GameObject

```
byte[] data = SerializationManager.SerializeToByteArray<GameObject>(gameObjectInstance);
```

#### Save List

```
List<GameObject> gameObjectsList = new List<GameObject>();
....
....
....
byte[] data = SerializationManager.SerializeToByteArray<List<GameObject>>(gameObjectList);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://assetstore.easysave.voxelbusters.com/tutorials/advanced/get-as-byte-stream.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
