# OptionalContentMembershipDict Class

> Attaches content to one or more optional content groups.

- Product: Adobe PDF Library 21
- Language: .NET Framework
- Version: APDFL21.0.0PlusP1e
- HTML page: https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/OptionalContentMembershipDict
- Version index: https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/llms.txt

```csharp
class OptionalContentMembershipDict : SystemIDisposable
```

**Namespace:** `Datalogics::PDFL`

**Inherits from:** `SystemIDisposable`

## Description

Attaches content to one or more optional content groups.

Form, container, and annotation objects can be associated with one or more optional content groups. By associating them with an optional content group, they become part of that 'layer', and the user can control the visibility of the content.

Note that by placing other element objects in a container, they can also be associated with an optional content group.

An OptionalContentMembershipDict connects content to the OptionalContentGroup; it contains a list of OptionalContentGroups, and rules for determining visibility when the OptionalContentGroups have conflicting on/off states in the active OptionalContentContext.

An OptionalContentMembershipDict cannot be changed once created; you must create a new OptionalContentMembershipDict and change the objects to point to it.

**Referenced by:** [`Annotation`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/Annotation.md), [`CircleAnnotation`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/CircleAnnotation.md), [`Container`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/Container.md), [`Form`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/Form.md), [`FreeTextAnnotation`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/FreeTextAnnotation.md), [`HighlightAnnotation`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/HighlightAnnotation.md), [`InkAnnotation`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/InkAnnotation.md), [`LineAnnotation`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/LineAnnotation.md), [`LinkAnnotation`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/LinkAnnotation.md), [`PolyLineAnnotation`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/PolyLineAnnotation.md), [`PolygonAnnotation`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/PolygonAnnotation.md), [`Redaction`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/Redaction.md), [`SquareAnnotation`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/SquareAnnotation.md), [`TextMarkupAnnotation`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/TextMarkupAnnotation.md), [`UnderlineAnnotation`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/UnderlineAnnotation.md)

**Uses types:** [`Document`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/Document.md), [`OptionalContentGroup`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/OptionalContentGroup.md), [`PDFArray`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/PDFArray.md), [`VisibilityPolicy`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/enum/VisibilityPolicy.md)

## Constructors

### OptionalContentMembershipDict

```csharp
Datalogics.PDFL.OptionalContentMembershipDict.OptionalContentMembershipDict(Document doc, System.Collections.Generic.IList< OptionalContentGroup > ocgs, VisibilityPolicy vp)
```

*constructor*

**Parameters**

- `doc` ([`Document`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/Document.md)): The document that the new OptionalContentMembershipDict will belong to.
- `ocgs` ([`System.Collections.Generic.IList< OptionalContentGroup >`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/OptionalContentGroup.md)): The list of OptionalContentGroups this MembershipDict refers to.
- `vp` ([`VisibilityPolicy`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/enum/VisibilityPolicy.md)): The VisibilityPolicy of this MembershipDict.

Create a new OptionalContentMembershipDict.

### OptionalContentMembershipDict

```csharp
Datalogics.PDFL.OptionalContentMembershipDict.OptionalContentMembershipDict(Document doc, System.Collections.Generic.IList< OptionalContentGroup > ocgs, VisibilityPolicy vp, PDFArray visibilityExpression)
```

*constructor*

**Parameters**

- `doc` ([`Document`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/Document.md)): The document that the new OptionalContentMembershipDict will belong to.
- `ocgs` ([`System.Collections.Generic.IList< OptionalContentGroup >`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/OptionalContentGroup.md)): The list of OptionalContentGroups this MembershipDict refers to.
- `vp` ([`VisibilityPolicy`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/enum/VisibilityPolicy.md)): The VisibilityPolicy of this MembershipDict.
- `visibilityExpression` ([`PDFArray`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/PDFArray.md)): The VisibilityExpression of this MembershipDict.

Create a new OptionalContentMembershipDict.

## Properties

### OptionalContentGroups

```csharp
System.Collections.Generic.IList<OptionalContentGroup> Datalogics.PDFL.OptionalContentMembershipDict.OptionalContentGroups { get; }
```

Gets the list of OptionalContentGroups for this membership dictionary. This may consist of one OCG or several.

### VisibilityExpression

```csharp
PDFArray Datalogics.PDFL.OptionalContentMembershipDict.VisibilityExpression { get; }
```

GetVisibilityExpression Gets the Visibility Expression for this membership dictionary.

### VisibilityPolicy

```csharp
VisibilityPolicy Datalogics.PDFL.OptionalContentMembershipDict.VisibilityPolicy { get; }
```

Gets the Visbility Policy for this membership dictionary.

## Methods

### Dispose

```csharp
void Datalogics.PDFL.OptionalContentMembershipDict.Dispose()
```

**Returns:** `void`

### Equals

```csharp
override bool Datalogics.PDFL.OptionalContentMembershipDict.Equals(object obj)
```

**Parameters**

- `obj` (`object`)

**Returns:** `override bool`

### ToString

```csharp
override string Datalogics.PDFL.OptionalContentMembershipDict.ToString()
```

**Returns:** `override string`

A string describing this OptionalContentMembershipDict.

Returns a string representation of this OptionalContentMembershipDict.

The string includes the names of all associated OptionalContentGroups and the current VisibilityPolicy.
