# OpcNodeHistory&lt;T&gt; Members

> Reference: Represents a history of values kept in memory in ascending order of their timestamps, with at most one value per timestamp.

<dl class="api-definition">
<dt>Type</dt>
<dd><a href="./">OpcNodeHistory&lt;T&gt;</a></dd>
<dt>Namespace</dt>
<dd><a href="../namespaces/opc.uafx.server">Opc.UaFx.Server</a></dd>
<dt>Assembly</dt>
<dd>Opc.UaFx.Advanced.dll</dd>
<dt>Package</dt>
<dd>Opc.UaFx.Advanced v2.59.0</dd>
</dl>

## Constructors

### OpcNodeHistory

<span class="api-meta">6 overloads</span>

| Overload | Description |
|---|---|
| [OpcNodeHistory()](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#opcnodehistory-noparams) | Initializes a new instance of the [OpcNodeHistory&lt;T&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/) class whose [Capacity](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#capacity) is -1 (unlimited). |
| [OpcNodeHistory(int)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#opcnodehistory-system-int32) | Initializes a new instance of the [OpcNodeHistory&lt;T&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/) class using the `capacity` specified. |
| [OpcNodeHistory(IEnumerable&lt;T&gt;)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#opcnodehistory-system-collections-generic-ienumerable-of-t0) | Initializes a new instance of the [OpcNodeHistory&lt;T&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/) class using the `values` specified. |
| [OpcNodeHistory(int, IEnumerable&lt;T&gt;)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#opcnodehistory-system-int32-system-collections-generic-ienumerable-of-t0) | Initializes a new instance of the [OpcNodeHistory&lt;T&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/) class using the `capacity` and `values` specified. |
| [OpcNodeHistory(params T\[\])](#opcnodehistory-t0-array) | Initializes a new instance of the [OpcNodeHistory&lt;T&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/) class using the `values` specified. |
| [OpcNodeHistory(int, params T\[\])](#opcnodehistory-system-int32-t0-array) | Initializes a new instance of the [OpcNodeHistory&lt;T&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/) class using the `capacity` and `values` specified. |

#### OpcNodeHistory()

Initializes a new instance of the [OpcNodeHistory&lt;T&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/) class whose [Capacity](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#capacity) is -1 (unlimited).

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

```csharp
public OpcNodeHistory()
```

</div>

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

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

</div>

#### OpcNodeHistory(int)

Initializes a new instance of the [OpcNodeHistory&lt;T&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/) class using the `capacity` specified.

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

```csharp
public OpcNodeHistory(int capacity)
```

</div>

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

```vbnet
Public Sub New(capacity As Integer)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `capacity` | [Int32](https://learn.microsoft.com/dotnet/api/system.int32) | The maximum number of values the history keeps: -1 (unlimited) or a positive number. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentOutOfRangeException](https://learn.microsoft.com/dotnet/api/system.argumentoutofrangeexception) | The `capacity` is 0 or less than -1. |

#### OpcNodeHistory(IEnumerable&lt;T&gt;)

Initializes a new instance of the [OpcNodeHistory&lt;T&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/) class using the `values` specified. The number of values the history keeps is not limited.

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

```csharp
public OpcNodeHistory(IEnumerable<T> values)
```

</div>

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

```vbnet
Public Sub New(values As IEnumerable(Of T))
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `values` | [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)&lt;T&gt; | A sequence of the values to add to the history. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception) | Two of the `values` have the same timestamp. |
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `values` or one of its items is a null reference (Nothing in Visual Basic). |

#### OpcNodeHistory(int, IEnumerable&lt;T&gt;)

Initializes a new instance of the [OpcNodeHistory&lt;T&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/) class using the `capacity` and `values` specified.

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

```csharp
public OpcNodeHistory(int capacity, IEnumerable<T> values)
```

</div>

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

```vbnet
Public Sub New(capacity As Integer, values As IEnumerable(Of T))
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `capacity` | [Int32](https://learn.microsoft.com/dotnet/api/system.int32) | The maximum number of values the history keeps: -1 (unlimited) or a positive number. |
| `values` | [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)&lt;T&gt; | A sequence of the values to add to the history. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception) | Two of the added `values` have the same timestamp. |
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `values` or one of the added items is a null reference (Nothing in Visual Basic). |
| [ArgumentOutOfRangeException](https://learn.microsoft.com/dotnet/api/system.argumentoutofrangeexception) | The `capacity` is 0 or less than -1. |

**Remarks**

If the `capacity` is not -1, only the last `capacity` items of the sequence are added, regardless of their timestamps.

#### OpcNodeHistory(params T\[\])

Initializes a new instance of the [OpcNodeHistory&lt;T&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/) class using the `values` specified. The number of values the history keeps is not limited.

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

```csharp
public OpcNodeHistory(params T[] values)
```

</div>

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

```vbnet
Public Sub New(ParamArray values As T())
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `values` | params T[] | The values to add to the history. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception) | Two of the `values` have the same timestamp. |
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `values` or one of its items is a null reference (Nothing in Visual Basic). |

#### OpcNodeHistory(int, params T\[\])

Initializes a new instance of the [OpcNodeHistory&lt;T&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/) class using the `capacity` and `values` specified.

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

```csharp
public OpcNodeHistory(int capacity, params T[] values)
```

</div>

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

```vbnet
Public Sub New(capacity As Integer, ParamArray values As T())
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `capacity` | [Int32](https://learn.microsoft.com/dotnet/api/system.int32) | The maximum number of values the history keeps: -1 (unlimited) or a positive number. |
| `values` | params T[] | The values to add to the history. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception) | Two of the added `values` have the same timestamp. |
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `values` or one of the added items is a null reference (Nothing in Visual Basic). |
| [ArgumentOutOfRangeException](https://learn.microsoft.com/dotnet/api/system.argumentoutofrangeexception) | The `capacity` is 0 or less than -1. |

**Remarks**

If the `capacity` is not -1, only the last `capacity` items of the array are added, regardless of their timestamps.

## Properties

### Capacity

Gets the maximum number of values the history keeps.

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

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

</div>

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

```vbnet
Public ReadOnly Property Capacity As Integer
```

</div>

**Property value**

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

The maximum number of values: -1 (unlimited) or a positive number.

**Remarks**

When a value is added to a history which has reached its capacity, the value with the earliest timestamp is removed first, also if the value added is earlier, and the [Removed](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#removed) event is raised.

### Count

Gets the number of values in the history.

<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 values in the history.

### EnableRaisingEvents

Gets or sets a value indicating whether the history raises the events [Added](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#added), [Removed](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#removed) and [Replaced](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#replaced).

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

```csharp
public bool EnableRaisingEvents { get; set; }
```

</div>

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

```vbnet
Public Property EnableRaisingEvents As Boolean
```

</div>

**Property value**

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

The value true if the history raises the events; otherwise the value false. The default value is true.

### EndTime

Gets the latest timestamp of the values in the history.

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

```csharp
public DateTime? EndTime { get; }
```

</div>

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

```vbnet
Public ReadOnly Property EndTime As Date?
```

</div>

**Property value**

[Nullable](https://learn.microsoft.com/dotnet/api/system.nullable-1)&lt;[DateTime](https://learn.microsoft.com/dotnet/api/system.datetime)&gt;

The latest timestamp or a null reference (Nothing in Visual Basic) if the history is empty.

### StartTime

Gets the earliest timestamp of the values in the history.

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

```csharp
public DateTime? StartTime { get; }
```

</div>

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

```vbnet
Public ReadOnly Property StartTime As Date?
```

</div>

**Property value**

[Nullable](https://learn.microsoft.com/dotnet/api/system.nullable-1)&lt;[DateTime](https://learn.microsoft.com/dotnet/api/system.datetime)&gt;

The earliest timestamp or a null reference (Nothing in Visual Basic) if the history is empty.

## Methods

### Add

Adds the `value` specified to the history and raises the [Added](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#added) event.

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

```csharp
public void Add(T value)
```

</div>

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

```vbnet
Public Sub Add(value As T)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `value` | T | The value to add. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception) | The history already contains a value with the timestamp of the `value`. |
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `value` is a null reference (Nothing in Visual Basic). |

**Remarks**

If the history has reached its [Capacity](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#capacity), the value with the earliest timestamp is removed first.

### AddRange

<span class="api-meta">2 overloads</span>

| Overload | Description |
|---|---|
| [AddRange(IEnumerable&lt;T&gt;)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#addrange-system-collections-generic-ienumerable-of-t0) | Adds the `values` specified to the history and raises the [Added](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#added) event. |
| [AddRange(params T\[\])](#addrange-t0-array) | Adds the `values` specified to the history and raises the [Added](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#added) event. |

**Exceptions (all overloads)**

| Exception | Condition |
|---|---|
| [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception) | The history already contains a value with the timestamp of one of the `values`. |
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `values` or one of its items is a null reference (Nothing in Visual Basic). |

#### AddRange(IEnumerable&lt;T&gt;)

Adds the `values` specified to the history and raises the [Added](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#added) event.

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

```csharp
public void AddRange(IEnumerable<T> values)
```

</div>

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

```vbnet
Public Sub AddRange(values As IEnumerable(Of T))
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `values` | [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)&lt;T&gt; | A sequence of the values to add. |

**Remarks**

The values are added in the order of the sequence. If a value cannot be added, the method stops and throws the exception; the values added before remain in the history. For a value which already exists, the [Added](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#added) event provides the values added before; for an item which is a null reference, the event is not raised.

#### AddRange(params T\[\])

Adds the `values` specified to the history and raises the [Added](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#added) event.

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

```csharp
public void AddRange(params T[] values)
```

</div>

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

```vbnet
Public Sub AddRange(ParamArray values As T())
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `values` | params T[] | The values to add. |

**Remarks**

The values are added in the order of the array. If a value cannot be added, the method stops and throws the exception; the values added before remain in the history. For a value which already exists, the [Added](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#added) event provides the values added before; for an item which is a null reference, the event is not raised.

### Clear

Removes all values from the history and raises the [Removed](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#removed) event.

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

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

</div>

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

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

</div>

### Contains

<span class="api-meta">2 overloads</span>

| Overload | Description |
|---|---|
| [Contains(DateTime)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#contains-system-datetime) | Determines whether the history contains a value at the `timestamp` specified. |
| [Contains(T)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#contains-t0) | Determines whether the history contains the `value` specified. |

#### Contains(DateTime)

Determines whether the history contains a value at the `timestamp` specified.

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

```csharp
public bool Contains(DateTime timestamp)
```

</div>

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

```vbnet
Public Function Contains(timestamp As Date) As Boolean
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `timestamp` | [DateTime](https://learn.microsoft.com/dotnet/api/system.datetime) | The timestamp to look for. |

**Returns**

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

The value true if the history contains a value at the `timestamp`; otherwise the value false.

#### Contains(T)

Determines whether the history contains the `value` specified.

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

```csharp
public bool Contains(T value)
```

</div>

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

```vbnet
Public Function Contains(value As T) As Boolean
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `value` | T | The value to look for. |

**Returns**

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

The value true if the value of the history at the timestamp of the `value` is equal to the `value`; otherwise the value false.

**Exceptions**

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

### Enumerate

<span class="api-meta">3 overloads</span>

| Overload | Description |
|---|---|
| [Enumerate()](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#enumerate-noparams) | Enumerates the values of the history in ascending order of their timestamps. |
| [Enumerate(DateTime?)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#enumerate-system-nullable-of-system-datetime) |  |
| [Enumerate(DateTime?, DateTime?)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#enumerate-system-nullable-of-system-datetime-system-nullable-of-system-datetime) |  |

#### Enumerate()

Enumerates the values of the history in ascending order of their timestamps.

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

```csharp
public IEnumerable<T> Enumerate()
```

</div>

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

```vbnet
Public Function Enumerate() As IEnumerable(Of T)
```

</div>

**Returns**

[IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)&lt;T&gt;

A sequence of the values of the history.

**Remarks**

The history stays locked while the sequence is enumerated, so that other threads which access the history wait until the enumeration has completed or the enumerator has been disposed.

#### Enumerate(DateTime?)

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

```csharp
public IEnumerable<T> Enumerate(DateTime? startTime)
```

</div>

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

```vbnet
Public Function Enumerate(startTime As Date?) As IEnumerable(Of T)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `startTime` | [Nullable](https://learn.microsoft.com/dotnet/api/system.nullable-1)&lt;[DateTime](https://learn.microsoft.com/dotnet/api/system.datetime)&gt; |  |

**Returns**

[IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)&lt;T&gt;

#### Enumerate(DateTime?, DateTime?)

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

```csharp
public IEnumerable<T> Enumerate(DateTime? startTime, DateTime? endTime)
```

</div>

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

```vbnet
Public Function Enumerate(
    startTime As Date?,
    endTime As Date?) As IEnumerable(Of T)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `startTime` | [Nullable](https://learn.microsoft.com/dotnet/api/system.nullable-1)&lt;[DateTime](https://learn.microsoft.com/dotnet/api/system.datetime)&gt; |  |
| `endTime` | [Nullable](https://learn.microsoft.com/dotnet/api/system.nullable-1)&lt;[DateTime](https://learn.microsoft.com/dotnet/api/system.datetime)&gt; |  |

**Returns**

[IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)&lt;T&gt;

### GetEnumerator

Returns an enumerator which iterates through the values of the history in ascending order of their timestamps.

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

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

</div>

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

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

</div>

**Returns**

[IEnumerator](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerator-1)&lt;T&gt;

An enumerator for the values of the history.

**Implements**

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

**Remarks**

The history stays locked while the enumerator is used, so that other threads which access the history wait until the enumeration has completed or the enumerator has been disposed.

### OnAdded

<span class="api-meta">protected · virtual</span>

Raises the [Added](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#added) event using the specified event data.

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

```csharp
protected virtual void OnAdded(OpcNodeHistoryEventArgs<T> e)
```

</div>

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

```vbnet
Protected Overridable Sub OnAdded(e As OpcNodeHistoryEventArgs(Of T))
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `e` | [OpcNodeHistoryEventArgs](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistoryeventargs-1/)&lt;T&gt; | The [OpcNodeHistoryEventArgs&lt;T&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistoryeventargs-1/) with the values added. |

### OnRemoved

<span class="api-meta">protected · virtual</span>

Raises the [Removed](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#removed) event using the specified event data.

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

```csharp
protected virtual void OnRemoved(OpcNodeHistoryEventArgs<T> e)
```

</div>

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

```vbnet
Protected Overridable Sub OnRemoved(e As OpcNodeHistoryEventArgs(Of T))
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `e` | [OpcNodeHistoryEventArgs](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistoryeventargs-1/)&lt;T&gt; | The [OpcNodeHistoryEventArgs&lt;T&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistoryeventargs-1/) with the values removed. |

### OnReplaced

<span class="api-meta">protected · virtual</span>

Raises the [Replaced](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#replaced) event using the specified event data.

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

```csharp
protected virtual void OnReplaced(OpcNodeHistoryEventArgs<T> e)
```

</div>

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

```vbnet
Protected Overridable Sub OnReplaced(e As OpcNodeHistoryEventArgs(Of T))
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `e` | [OpcNodeHistoryEventArgs](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistoryeventargs-1/)&lt;T&gt; | The [OpcNodeHistoryEventArgs&lt;T&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistoryeventargs-1/) with the values replaced. |

### Remove

Removes the `value` specified from the history and raises the [Removed](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#removed) event.

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

```csharp
public bool Remove(T value)
```

</div>

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

```vbnet
Public Function Remove(value As T) As Boolean
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `value` | T | The value to remove. |

**Returns**

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

The value true if the history contained the `value` (see [Contains](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#contains-t0)) and the value has been removed; otherwise the value false.

**Exceptions**

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

### RemoveAt

<span class="api-meta">4 overloads</span>

| Overload | Description |
|---|---|
| [RemoveAt(int)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#removeat-system-int32) | Removes the value at the `index` specified in the ascending order of the timestamps and raises the [Removed](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#removed) event. |
| [RemoveAt(DateTime)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#removeat-system-datetime) | Removes the value at the `timestamp` specified and raises the [Removed](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#removed) event. |
| [RemoveAt(IEnumerable&lt;DateTime&gt;)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#removeat-system-collections-generic-ienumerable-of-system-datetime) | Removes the values at the `timestamps` specified and raises the [Removed](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#removed) event. |
| [RemoveAt(params DateTime\[\])](#removeat-system-datetime-array) | Removes the values at the `timestamps` specified and raises the [Removed](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#removed) event. |

#### RemoveAt(int)

Removes the value at the `index` specified in the ascending order of the timestamps and raises the [Removed](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#removed) event.

<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 value 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.server.opcnodehistory-1/members#count). |

#### RemoveAt(DateTime)

Removes the value at the `timestamp` specified and raises the [Removed](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#removed) event.

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

```csharp
public void RemoveAt(DateTime timestamp)
```

</div>

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

```vbnet
Public Sub RemoveAt(timestamp As Date)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `timestamp` | [DateTime](https://learn.microsoft.com/dotnet/api/system.datetime) | The timestamp of the value to remove. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentOutOfRangeException](https://learn.microsoft.com/dotnet/api/system.argumentoutofrangeexception) | The history contains no value at the `timestamp`. |

#### RemoveAt(IEnumerable&lt;DateTime&gt;)

Removes the values at the `timestamps` specified and raises the [Removed](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#removed) event.

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

```csharp
public void RemoveAt(IEnumerable<DateTime> timestamps)
```

</div>

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

```vbnet
Public Sub RemoveAt(timestamps As IEnumerable(Of Date))
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `timestamps` | [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)&lt;[DateTime](https://learn.microsoft.com/dotnet/api/system.datetime)&gt; | A sequence of the timestamps of the values to remove. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `timestamps` is a null reference (Nothing in Visual Basic). |
| [ArgumentOutOfRangeException](https://learn.microsoft.com/dotnet/api/system.argumentoutofrangeexception) | The history contains no value at one of the `timestamps`. |

**Remarks**

The values are removed in the order of the sequence. If the history contains no value at a timestamp, the method stops and throws the exception; the values removed before stay removed.

#### RemoveAt(params DateTime\[\])

Removes the values at the `timestamps` specified and raises the [Removed](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#removed) event.

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

```csharp
public void RemoveAt(params DateTime[] timestamps)
```

</div>

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

```vbnet
Public Sub RemoveAt(ParamArray timestamps As Date())
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `timestamps` | params [DateTime](https://learn.microsoft.com/dotnet/api/system.datetime)[] | The timestamps of the values to remove. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `timestamps` is a null reference (Nothing in Visual Basic). |
| [ArgumentOutOfRangeException](https://learn.microsoft.com/dotnet/api/system.argumentoutofrangeexception) | The history contains no value at one of the `timestamps`. |

**Remarks**

The values are removed in the order of the array. If the history contains no value at a timestamp, the method stops and throws the exception; the values removed before stay removed.

### RemoveRange

<span class="api-meta">2 overloads</span>

| Overload | Description |
|---|---|
| [RemoveRange(DateTime?)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#removerange-system-nullable-of-system-datetime) |  |
| [RemoveRange(DateTime?, DateTime?)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#removerange-system-nullable-of-system-datetime-system-nullable-of-system-datetime) |  |

#### RemoveRange(DateTime?)

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

```csharp
public void RemoveRange(DateTime? startTime)
```

</div>

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

```vbnet
Public Sub RemoveRange(startTime As Date?)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `startTime` | [Nullable](https://learn.microsoft.com/dotnet/api/system.nullable-1)&lt;[DateTime](https://learn.microsoft.com/dotnet/api/system.datetime)&gt; |  |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentOutOfRangeException](https://learn.microsoft.com/dotnet/api/system.argumentoutofrangeexception) |  |

#### RemoveRange(DateTime?, DateTime?)

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

```csharp
public void RemoveRange(DateTime? startTime, DateTime? endTime)
```

</div>

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

```vbnet
Public Sub RemoveRange(startTime As Date?, endTime As Date?)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `startTime` | [Nullable](https://learn.microsoft.com/dotnet/api/system.nullable-1)&lt;[DateTime](https://learn.microsoft.com/dotnet/api/system.datetime)&gt; |  |
| `endTime` | [Nullable](https://learn.microsoft.com/dotnet/api/system.nullable-1)&lt;[DateTime](https://learn.microsoft.com/dotnet/api/system.datetime)&gt; |  |

### Replace

Replaces the value at the timestamp of the `value` specified with the `value` and raises the [Replaced](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#replaced) event.

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

```csharp
public void Replace(T value)
```

</div>

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

```vbnet
Public Sub Replace(value As T)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `value` | T | The new value. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception) | The history contains no value at the timestamp of the `value`. |
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `value` is a null reference (Nothing in Visual Basic). |

## Events

### Added

Occurs after values have been added to the history.

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

```csharp
public event EventHandler<OpcNodeHistoryEventArgs<T>> Added
```

</div>

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

```vbnet
Public Event Added As EventHandler(Of OpcNodeHistoryEventArgs(Of T))
```

</div>

**Event type**

[EventHandler](https://learn.microsoft.com/dotnet/api/system.eventhandler-1)&lt;[OpcNodeHistoryEventArgs](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistoryeventargs-1/)&lt;T&gt;&gt;

**Remarks**

A method which adds several values raises the event once for all values added, also if no value has been added. The event is not raised while [EnableRaisingEvents](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#enableraisingevents) is false.

### Removed

Occurs after values have been removed from the history, also if a value has been removed because the history reached its [Capacity](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#capacity).

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

```csharp
public event EventHandler<OpcNodeHistoryEventArgs<T>> Removed
```

</div>

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

```vbnet
Public Event Removed As EventHandler(Of OpcNodeHistoryEventArgs(Of T))
```

</div>

**Event type**

[EventHandler](https://learn.microsoft.com/dotnet/api/system.eventhandler-1)&lt;[OpcNodeHistoryEventArgs](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistoryeventargs-1/)&lt;T&gt;&gt;

**Remarks**

A method which removes several values raises the event once for all values removed, also if no value has been removed. The event is not raised while [EnableRaisingEvents](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#enableraisingevents) is false.

### Replaced

Occurs after a value of the history has been replaced.

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

```csharp
public event EventHandler<OpcNodeHistoryEventArgs<T>> Replaced
```

</div>

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

```vbnet
Public Event Replaced As EventHandler(Of OpcNodeHistoryEventArgs(Of T))
```

</div>

**Event type**

[EventHandler](https://learn.microsoft.com/dotnet/api/system.eventhandler-1)&lt;[OpcNodeHistoryEventArgs](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistoryeventargs-1/)&lt;T&gt;&gt;

**Remarks**

The [Values](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistoryeventargs-1/members#values) of the event data provide the values which have been replaced, not the new values. The event is not raised while [EnableRaisingEvents](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#enableraisingevents) is false.

## Indexers

### Item

<span class="api-meta">2 overloads</span>

| Overload | Description |
|---|---|
| [this\[int\]](#item-system-int32) | Gets or sets the value at the `index` specified in the ascending order of the timestamps. |
| [this\[DateTime\]](#item-system-datetime) | Gets or sets the value at the `timestamp` specified. |

#### this\[int\]

Gets or sets the value at the `index` specified in the ascending order of the timestamps.

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

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

</div>

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

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

</div>

**Parameters**

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

**Property value**

T

The value at the `index` specified.

**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.server.opcnodehistory-1/members#count). |

**Remarks**

The setter replaces the value at the timestamp of the value at the `index` without comparing the timestamp of the new value and raises the [Replaced](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#replaced) event. To replace a value by its own timestamp use [Replace](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#replace).

#### this\[DateTime\]

Gets or sets the value at the `timestamp` specified.

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

```csharp
public T this[DateTime timestamp] { get; set; }
```

</div>

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

```vbnet
Public Default Property this[](timestamp As Date) As T
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `timestamp` | [DateTime](https://learn.microsoft.com/dotnet/api/system.datetime) | The timestamp of the value. |

**Property value**

T

The value at the `timestamp` specified.

**Exceptions**

| Exception | Condition |
|---|---|
| [KeyNotFoundException](https://learn.microsoft.com/dotnet/api/system.collections.generic.keynotfoundexception) | The history contains no value at the `timestamp` specified. |

**Remarks**

The setter replaces the value at the `timestamp` without comparing the timestamp of the new value and raises the [Replaced](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#replaced) event. To replace a value by its own timestamp use [Replace](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.server.opcnodehistory-1/members#replace).
