# IDurableStateManager.GetOrAddState(string)

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.idurablestatemanager/) | [Methods](/orleans/docs/api/csharp/microsoft.orleans.journaling/orleans.journaling.idurablestatemanager/methods/)

```csharp
public abstract TState GetOrAddState<TState>(string name)
```

Gets an existing state component or creates it using the registered implementation of its application contract.

### Parameters

- `name` (`string`): The stable, ordinal, case-sensitive state name.

### Returns

The existing or newly created state instance.

### Exceptions

- `System.InvalidOperationException`: The name has an incompatible state type, the contract is not registered, or initialization has begun and the state does not exist.
