# Class Extension&lt;TTarget, TValue&gt; (3.27.1)

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

- [3.27.1 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Extension-2)
- [3.23.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/3.23.0/Google.Protobuf.Extension-2)
- [3.15.8](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/3.15.8/Google.Protobuf.Extension-2)

    public sealed class Extension<TTarget, TValue> : Extension where TTarget : IExtendableMessage<TTarget>

Represents a type-safe extension identifier used for getting and setting single extension values in [IExtendableMessage\<T\>](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IExtendableMessage-1) instances.
This API is experimental and subject to change.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> [Extension](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Extension) \> Extension\<TTarget, TValue\>

## Inherited Members

[Extension.FieldNumber](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Extension#Google_Protobuf_Extension_FieldNumber) [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.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals) [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Namespace

[Google.Protobuf](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf)

## Assembly

Google.Protobuf.dll

| ## Type Parameters ||
|---|---|
| **Name** | **Description** |
| `TTarget` | The message type this field applies to |
| `TValue` | The field value type of this extension |

## Constructors

### Extension(int, FieldCodec\<TValue\>)

    public Extension(int fieldNumber, FieldCodec<TValue> codec)

Creates a new extension identifier with the specified field number and codec

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `fieldNumber` | `https://learn.microsoft.com/dotnet/api/system.int32` |
| `codec` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.FieldCodec-1` |