# Class Marshaller&lt;T&gt; (2.66.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [2.66.0 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.Marshaller-1)
- [2.63.0](https://docs.cloud.google.com/dotnet/docs/reference/Grpc.Core/2.63.0/Grpc.Core.Marshaller-1)
- [2.48.0](https://docs.cloud.google.com/dotnet/docs/reference/Grpc.Core/2.48.0/Grpc.Core.Marshaller-1)

    public class Marshaller<T>

Encapsulates the logic for serializing and deserializing messages.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> Marshaller\<T\>

## Inherited Members

[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)) [object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)) [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone) [object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals) [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Namespace

[Grpc.Core](https://docs.cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core)

## Assembly

Grpc.Core.Api.dll

| ## Type Parameter ||
|---|---|
| **Name** | **Description** |
| `T` |   |

## Constructors

### Marshaller(Action\<T, SerializationContext\>, Func\<DeserializationContext, T\>)

    public Marshaller(Action<T, SerializationContext> serializer, Func<DeserializationContext, T> deserializer)

Initializes a new marshaller from serialize/deserialize fuctions that can access serialization and deserialization
context. Compared to the simple serializer/deserializer functions, using the contextual version provides more
flexibility and can lead to increased efficiency (and better performance).
Note: This constructor is part of an experimental API that can change or be removed without any prior notice.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `serializer` | `https://learn.microsoft.com/dotnet/api/system.action-2https://docs.cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.SerializationContext` Function that will be used to serialize messages. |
| `deserializer` | `https://learn.microsoft.com/dotnet/api/system.func-2https://docs.cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.DeserializationContext` Function that will be used to deserialize messages. |

### Marshaller(Func\<T, byte\[\]\>, Func\<byte\[\], T\>)

    public Marshaller(Func<T, byte[]> serializer, Func<byte[], T> deserializer)

Initializes a new marshaller from simple serialize/deserialize functions.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `serializer` | `https://learn.microsoft.com/dotnet/api/system.func-2System.Byte` Function that will be used to serialize messages. |
| `deserializer` | `https://learn.microsoft.com/dotnet/api/system.func-2System.Byte` Function that will be used to deserialize messages. |

## Properties

### ContextualDeserializer

    public Func<DeserializationContext, T> ContextualDeserializer { get; }

Gets the serializer function.
Note: experimental API that can change or be removed without any prior notice.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.func-2https://docs.cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.DeserializationContext` |   |

### ContextualSerializer

    public Action<T, SerializationContext> ContextualSerializer { get; }

Gets the serializer function.
Note: experimental API that can change or be removed without any prior notice.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.action-2https://docs.cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.SerializationContext` |   |

### Deserializer

    public Func<byte[], T> Deserializer { get; }

Gets the deserializer function.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.func-2System.Byte` |   |

### Serializer

    public Func<T, byte[]> Serializer { get; }

Gets the serializer function.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.func-2System.Byte` |   |