# Class Expiration (4.10.0)

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

- [4.10.0 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Expiration)
- [4.8.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/4.8.0/Google.Api.Gax.Expiration)
- [4.4.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/4.4.0/Google.Api.Gax.Expiration)
- [4.3.1](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/4.3.1/Google.Api.Gax.Expiration)
- [4.2.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/4.2.0/Google.Api.Gax.Expiration)
- [4.0.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/4.0.0/Google.Api.Gax.Expiration)
- [3.2.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/3.2.0/Google.Api.Gax.Expiration)

    public sealed class Expiration

Expiration specified by relative timeout or absolute deadline.

## Inheritance

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

## 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.Api.Gax](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax)

## Assembly

Google.Api.Gax.dll

## Properties

### Deadline

    public DateTime? Deadline { get; }

If not null, the absolute deadline of this expiration.

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

### None

    public static Expiration None { get; }

An [Expiration](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Expiration) with no timeout or deadline.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Expiration` |   |

**Remarks** Indicates that no expiration is required.

### Timeout

    public TimeSpan? Timeout { get; }

If not null, the relative timeout of this expiration.

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

### Type

    public ExpirationType Type { get; }

What [ExpirationType](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.ExpirationType) is contained in this [Expiration](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Expiration).

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.ExpirationType` |   |

## Methods

### FromDeadline(DateTime)

    public static Expiration FromDeadline(DateTime deadline)

Create an [Expiration](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Expiration) with an absolute deadline.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `deadline` | `https://learn.microsoft.com/dotnet/api/system.datetime` The absolute deadline. Should be a UTC datetime. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Expiration` | An [Expiration](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Expiration) with the specified absolute deadline. |

**Remarks** Deadlines in the past are valid, and will cause immediate failure of the operation being performed.

### FromTimeout(TimeSpan)

    public static Expiration FromTimeout(TimeSpan timeout)

Create an [Expiration](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Expiration) with a relative timeout.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `timeout` | `https://learn.microsoft.com/dotnet/api/system.timespan` The relative timeout. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Expiration` | An [Expiration](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Expiration) with the specified relative timeout. |

**Remarks** Zero or negative timeouts are valid, and will cause immediate failure of the operation being performed.

## Extension Method

[ExpirationExtensions.CalculateDeadline(Expiration, IClock)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.ExpirationExtensions#Google_Api_Gax_ExpirationExtensions_CalculateDeadline_Google_Api_Gax_Expiration_Google_Api_Gax_IClock_)