# Class ExtensionRegistry (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.ExtensionRegistry)
- [3.23.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/3.23.0/Google.Protobuf.ExtensionRegistry)
- [3.15.8](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/3.15.8/Google.Protobuf.ExtensionRegistry)

    public sealed class ExtensionRegistry : ICollection<Extension>, IEnumerable<Extension>, IEnumerable, IDeepCloneable<ExtensionRegistry>

Provides extensions to messages while parsing. This API is experimental and subject to change.

## Inheritance

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

## Implements

[ICollection](https://learn.microsoft.com/dotnet/api/system.collections.generic.icollection-1)[Extension](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Extension), [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)[Extension](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Extension), [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.ienumerable), [IDeepCloneable](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IDeepCloneable-1)[ExtensionRegistry](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.ExtensionRegistry)

## 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.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

## Constructors

### ExtensionRegistry()

    public ExtensionRegistry()

Creates a new empty extension registry

## Properties

### Count

    public int Count { get; }

Gets the total number of extensions in this extension registry

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.int32` |   |

## Methods

### Add(Extension)

    public void Add(Extension extension)

Adds the specified extension to the registry

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `extension` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Extension` |

### AddRange(IEnumerable\<Extension\>)

    public void AddRange(IEnumerable<Extension> extensions)

Adds the specified extensions to the registry

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `extensions` | `https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Extension` |

### Clear()

    public void Clear()

Clears the registry of all values

### Clone()

    public ExtensionRegistry Clone()

Clones the registry into a new registry

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.ExtensionRegistry` |   |

### Contains(Extension)

    public bool Contains(Extension item)

Gets whether the extension registry contains the specified extension

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `item` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Extension` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.boolean` |   |

### GetEnumerator()

    public IEnumerator<Extension> GetEnumerator()

Returns an enumerator to enumerate through the items in the registry

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerator-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Extension` | Returns an enumerator for the extensions in this registry |

### Remove(Extension)

    public bool Remove(Extension item)

Removes the specified extension from the set

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `item` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Extension` The extension |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.boolean` | `true` if the extension was removed, otherwise `false` |