# OpcSecurityPolicyCollection Members

> Reference: Represents a collection of the security policies of endpoints (see EndpointPolicies).

<dl class="api-definition">
<dt>Type</dt>
<dd><a href="./">OpcSecurityPolicyCollection</a></dd>
<dt>Namespace</dt>
<dd><a href="../namespaces/opc.uafx">Opc.UaFx</a></dd>
<dt>Assembly</dt>
<dd>Opc.UaFx.Advanced.dll</dd>
<dt>Package</dt>
<dd>Opc.UaFx.Advanced v2.59.0</dd>
</dl>

## Constructors

### OpcSecurityPolicyCollection

<span class="api-meta">since v2.6</span>

Initializes a new instance of the [OpcSecurityPolicyCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcsecuritypolicycollection/) class, which is empty.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcSecurityPolicyCollection()
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Sub New()
```

</div>

## Properties

### Count

Gets the number of security policies in the collection.

<div class="api-signature" data-lang="csharp">

```csharp
public int Count { get; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public ReadOnly Property Count As Integer
```

</div>

**Property value**

[Int32](https://learn.microsoft.com/dotnet/api/system.int32)

The number of security policies in the collection.

**Implements**

[Count](https://learn.microsoft.com/dotnet/api/system.collections.generic.icollection-1.count)

### IsReadOnly

Gets a value indicating whether the collection is read-only.

<div class="api-signature" data-lang="csharp">

```csharp
public bool IsReadOnly { get; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public ReadOnly Property IsReadOnly As Boolean
```

</div>

**Property value**

[Boolean](https://learn.microsoft.com/dotnet/api/system.boolean)

Always the value false.

**Implements**

[IsReadOnly](https://learn.microsoft.com/dotnet/api/system.collections.generic.icollection-1.isreadonly)

## Methods

### Add

Adds the security policy specified to the end of the collection.

<div class="api-signature" data-lang="csharp">

```csharp
public void Add(OpcSecurityPolicy item)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Sub Add(item As OpcSecurityPolicy)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `item` | [OpcSecurityPolicy](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcsecuritypolicy/) | The security policy to add. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `item` is a null reference (Nothing in Visual Basic). |

**Implements**

[Add(OpcSecurityPolicy)](https://learn.microsoft.com/dotnet/api/system.collections.generic.icollection-1.add)

### Clear

Removes all security policies from the collection.

<div class="api-signature" data-lang="csharp">

```csharp
public void Clear()
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Sub Clear()
```

</div>

**Implements**

[Clear()](https://learn.microsoft.com/dotnet/api/system.collections.generic.icollection-1.clear)

### Contains

Determines whether the collection contains the security policy specified.

<div class="api-signature" data-lang="csharp">

```csharp
public bool Contains(OpcSecurityPolicy item)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Function Contains(item As OpcSecurityPolicy) As Boolean
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `item` | [OpcSecurityPolicy](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcsecuritypolicy/) | The security policy to locate. |

**Returns**

[Boolean](https://learn.microsoft.com/dotnet/api/system.boolean)

The value true if the collection contains the `item`; otherwise the value false.

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `item` is a null reference (Nothing in Visual Basic). |

**Implements**

[Contains(OpcSecurityPolicy)](https://learn.microsoft.com/dotnet/api/system.collections.generic.icollection-1.contains)

### CopyTo

Copies the security policies of the collection to the `array` specified, starting at the `arrayIndex` specified.

<div class="api-signature" data-lang="csharp">

```csharp
public void CopyTo(OpcSecurityPolicy[] array, int arrayIndex)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Sub CopyTo(array As OpcSecurityPolicy(), arrayIndex As Integer)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `array` | [OpcSecurityPolicy](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcsecuritypolicy/)[] | The array to copy the security policies to. |
| `arrayIndex` | [Int32](https://learn.microsoft.com/dotnet/api/system.int32) | The zero-based index in the `array` at which copying begins. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `array` is a null reference (Nothing in Visual Basic). |
| [ArgumentOutOfRangeException](https://learn.microsoft.com/dotnet/api/system.argumentoutofrangeexception) | The `arrayIndex` is less than zero. |
| [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception) | The number of security policies in the collection is greater than the space from `arrayIndex` to the end of the `array`. |

**Implements**

[CopyTo(OpcSecurityPolicy\[\], int)](https://learn.microsoft.com/dotnet/api/system.collections.generic.icollection-1.copyto)

### GetEnumerator

Returns an enumerator that iterates through the security policies of the collection.

<div class="api-signature" data-lang="csharp">

```csharp
public IEnumerator<OpcSecurityPolicy> GetEnumerator()
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Function GetEnumerator() As IEnumerator(Of OpcSecurityPolicy)
```

</div>

**Returns**

[IEnumerator](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerator-1)&lt;[OpcSecurityPolicy](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcsecuritypolicy/)&gt;

An enumerator for the security policies of the collection.

**Implements**

[GetEnumerator()](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1.getenumerator)

### IndexOf

Determines the index of the security policy specified in the collection.

<div class="api-signature" data-lang="csharp">

```csharp
public int IndexOf(OpcSecurityPolicy item)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Function IndexOf(item As OpcSecurityPolicy) As Integer
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `item` | [OpcSecurityPolicy](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcsecuritypolicy/) | The security policy to locate. |

**Returns**

[Int32](https://learn.microsoft.com/dotnet/api/system.int32)

The zero-based index of the `item`, or -1 if the collection does not contain it.

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `item` is a null reference (Nothing in Visual Basic). |

**Implements**

[IndexOf(OpcSecurityPolicy)](https://learn.microsoft.com/dotnet/api/system.collections.generic.ilist-1.indexof)

### Insert

Inserts the security policy specified at the `index` specified.

<div class="api-signature" data-lang="csharp">

```csharp
public void Insert(int index, OpcSecurityPolicy item)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Sub Insert(index As Integer, item As OpcSecurityPolicy)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `index` | [Int32](https://learn.microsoft.com/dotnet/api/system.int32) | The zero-based index at which the `item` is to be inserted. |
| `item` | [OpcSecurityPolicy](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcsecuritypolicy/) | The security policy to insert. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `item` is a null reference (Nothing in Visual Basic). |
| [ArgumentOutOfRangeException](https://learn.microsoft.com/dotnet/api/system.argumentoutofrangeexception) | The `index` is less than zero or greater than [Count](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcsecuritypolicycollection/members#count). |

**Implements**

[Insert(int, OpcSecurityPolicy)](https://learn.microsoft.com/dotnet/api/system.collections.generic.ilist-1.insert)

### Remove

Removes the security policy specified from the collection.

<div class="api-signature" data-lang="csharp">

```csharp
public bool Remove(OpcSecurityPolicy item)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Function Remove(item As OpcSecurityPolicy) As Boolean
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `item` | [OpcSecurityPolicy](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcsecuritypolicy/) | The security policy to remove. |

**Returns**

[Boolean](https://learn.microsoft.com/dotnet/api/system.boolean)

The value true if the `item` has been removed; otherwise the value false.

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `item` is a null reference (Nothing in Visual Basic). |

**Implements**

[Remove(OpcSecurityPolicy)](https://learn.microsoft.com/dotnet/api/system.collections.generic.icollection-1.remove)

### RemoveAt

Removes the security policy at the `index` specified.

<div class="api-signature" data-lang="csharp">

```csharp
public void RemoveAt(int index)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Sub RemoveAt(index As Integer)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `index` | [Int32](https://learn.microsoft.com/dotnet/api/system.int32) | The zero-based index of the security policy to remove. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentOutOfRangeException](https://learn.microsoft.com/dotnet/api/system.argumentoutofrangeexception) | The `index` is less than zero or not less than [Count](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcsecuritypolicycollection/members#count). |

**Implements**

[RemoveAt(int)](https://learn.microsoft.com/dotnet/api/system.collections.generic.ilist-1.removeat)

## Indexers

### Item

Gets or sets the security policy at the `index` specified.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcSecurityPolicy this[int index] { get; set; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Default Property this[](index As Integer) As OpcSecurityPolicy
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `index` | [Int32](https://learn.microsoft.com/dotnet/api/system.int32) | The zero-based index of the security policy. |

**Property value**

[OpcSecurityPolicy](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcsecuritypolicy/)

The security policy at the `index`.

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The value to set is a null reference (Nothing in Visual Basic). |
| [ArgumentOutOfRangeException](https://learn.microsoft.com/dotnet/api/system.argumentoutofrangeexception) | The `index` is less than zero or not less than [Count](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcsecuritypolicycollection/members#count). |

**Implements**

[this\[int\]](https://learn.microsoft.com/dotnet/api/system.int32)
