# DurableTask.GetVersion(string, int, int)

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/) | [Methods](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletask/methods/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable.Abstractions/DurableTask.Version.cs#L84-L89)

```csharp
public static int GetVersion(string name, int minSupported, int maxSupported)
```

Returns the version of the change `name` which the running durable task follows, so code which changes a workflow keeps replaying the executions which started before the change.

### Parameters

- `name` (`string`): The change's name within the running task, such as `"carrier-api"`. Every call with the same name in one execution returns the same version. Names don't contain `$`.
- `minSupported` (`int`): The oldest version which the calling code still supports. Version `0` is the code before the change's first version.
- `maxSupported` (`int`): The newest version, which executions that reach the call for the first time record.

### Returns

A version from `minSupported` to `maxSupported`.

### Exceptions

- `System.ArgumentNullException`: `name` is `null`.
- `System.ArgumentException`: `name` is empty or contains `$`.
- `System.ArgumentOutOfRangeException`: `minSupported` is negative, or `maxSupported` is less than `minSupported`.
- `Orleans.Durable.Tasks.DurableTaskAttemptCanceledException`: The host canceled the attempt, for example because the execution recorded a version outside the supported range, which stalls it; the exception's inner exception is then a [DurableTaskVersionException](/orleans/docs/api/csharp/microsoft.orleans.durable.abstractions/orleans.durable.tasks.durabletaskversionexception/).
- `System.InvalidOperationException`: The host can't record the version from the calling code, for example after `ConfigureAwait(false)`.
- `System.NotSupportedException`: The host doesn't support versions.

### Examples

```csharp
var version = DurableTask.GetVersion("carrier-api", minSupported: 0, maxSupported: 1);
            if (version >= 1)
            {
                await carrier.BookAsync(order).WithId("book");
            }
            else
            {
                await legacyShipping.ShipAsync(order).WithId("ship");
            }
```
