# ExpressionInterpolatedStringHandler Methods

- Package: [Aspire.Hosting](/reference/api/csharp/aspire.hosting.md)
- Type: [ExpressionInterpolatedStringHandler](/reference/api/csharp/aspire.hosting/expressioninterpolatedstringhandler.md)
- Kind: `Methods`
- Members: `8`

Represents a handler for interpolated strings that contain expressions. Those expressions will either be literal strings or instances of types that implement both [IValueProvider](/reference/api/csharp/aspire.hosting/ivalueprovider.md) and [IManifestExpressionProvider](/reference/api/csharp/aspire.hosting/imanifestexpressionprovider.md).

## AppendFormatted(string?)

- Name: `AppendFormatted(string?)`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/ReferenceExpression.cs#L347-L348)

Appends a formatted value to the expression.

```csharp
public struct ExpressionInterpolatedStringHandler
{
    public readonly void AppendFormatted(
        string? value)
    {
        // ...
    }
}
```

## Parameters

- `value` (`string?`)
  The formatted string to be appended to the interpolated string.

## AppendFormatted(string?, string?)

- Name: `AppendFormatted(string?, string?)`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/ReferenceExpression.cs#L359-L368)

Appends a formatted value to the expression.

```csharp
public struct ExpressionInterpolatedStringHandler
{
    public readonly void AppendFormatted(
        string? value,
        string? format = null)
    {
        // ...
    }
}
```

## Parameters

- `value` (`string?`)
  The formatted string to be appended to the interpolated string.
- `format` (`string?`) `optional`
  The format to be applied to the value. e.g., "uri"

## AppendFormatted(T)

- Name: `AppendFormatted(T)`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/ReferenceExpression.cs)

Appends a formatted value to the expression. The value must implement [IValueProvider](/reference/api/csharp/aspire.hosting/ivalueprovider.md) and [IManifestExpressionProvider](/reference/api/csharp/aspire.hosting/imanifestexpressionprovider.md).

```csharp
public struct ExpressionInterpolatedStringHandler
{
    public void AppendFormatted<T>(
        T valueProvider)
    {
        // ...
    }
}
```

## Parameters

- `valueProvider` (`T`)
  An instance of an object which implements [IValueProvider](/reference/api/csharp/aspire.hosting/ivalueprovider.md) and [IManifestExpressionProvider](/reference/api/csharp/aspire.hosting/imanifestexpressionprovider.md).

## Exceptions

- `InvalidOperationException`

## AppendFormatted(ReferenceExpression, string)

> **Obsolete:** ReferenceExpression instances can't be used in interpolated string with a custom format. Duplicate the inner expression in-place.

- Name: `AppendFormatted(ReferenceExpression, string)`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/ReferenceExpression.cs)

Appends the formatted value provided by the specified reference expression to the output.

```csharp
public struct ExpressionInterpolatedStringHandler
{
    public void AppendFormatted(
        ReferenceExpression valueProvider,
        string format)
    {
        // ...
    }
}
```

## Parameters

- `valueProvider` ([ReferenceExpression](/reference/api/csharp/aspire.hosting/referenceexpression.md))
  A reference expression that supplies the value to be formatted and appended.
- `format` (`string`)
  A composite format string that specifies how the value should be formatted, or null to use the default format.

## Remarks

This method is marked obsolete only to prevent usages of this type explicitly.

## AppendFormatted(T, string?)

- Name: `AppendFormatted(T, string?)`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/ReferenceExpression.cs)

Appends a formatted value to the expression. The value must implement [IValueProvider](/reference/api/csharp/aspire.hosting/ivalueprovider.md) and [IManifestExpressionProvider](/reference/api/csharp/aspire.hosting/imanifestexpressionprovider.md).

```csharp
public struct ExpressionInterpolatedStringHandler
{
    public void AppendFormatted<T>(
        T valueProvider,
        string? format = null)
    {
        // ...
    }
}
```

## Parameters

- `valueProvider` (`T`)
  An instance of an object which implements [IValueProvider](/reference/api/csharp/aspire.hosting/ivalueprovider.md) and [IManifestExpressionProvider](/reference/api/csharp/aspire.hosting/imanifestexpressionprovider.md).
- `format` (`string?`) `optional`
  The format to be applied to the value. e.g., "uri"

## Exceptions

- `InvalidOperationException`

## AppendFormatted(IResourceBuilder<T>)

- Name: `AppendFormatted(IResourceBuilder<T>)`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/ReferenceExpression.cs)

Appends a formatted value to the expression. The value must implement [IValueProvider](/reference/api/csharp/aspire.hosting/ivalueprovider.md) and [IManifestExpressionProvider](/reference/api/csharp/aspire.hosting/imanifestexpressionprovider.md).

```csharp
public struct ExpressionInterpolatedStringHandler
{
    public void AppendFormatted<T>(
        IResourceBuilder<T> valueProvider)
    {
        // ...
    }
}
```

## Parameters

- `valueProvider` ([IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md))
  An instance of an object which implements [IValueProvider](/reference/api/csharp/aspire.hosting/ivalueprovider.md) and [IManifestExpressionProvider](/reference/api/csharp/aspire.hosting/imanifestexpressionprovider.md).

## Exceptions

- `InvalidOperationException`

## AppendFormatted(IResourceBuilder<T>, string?)

- Name: `AppendFormatted(IResourceBuilder<T>, string?)`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/ReferenceExpression.cs)

Appends a formatted value to the expression. The value must implement [IValueProvider](/reference/api/csharp/aspire.hosting/ivalueprovider.md) and [IManifestExpressionProvider](/reference/api/csharp/aspire.hosting/imanifestexpressionprovider.md).

```csharp
public struct ExpressionInterpolatedStringHandler
{
    public void AppendFormatted<T>(
        IResourceBuilder<T> valueProvider,
        string? format = null)
    {
        // ...
    }
}
```

## Parameters

- `valueProvider` ([IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md))
  An instance of an object which implements [IValueProvider](/reference/api/csharp/aspire.hosting/ivalueprovider.md) and [IManifestExpressionProvider](/reference/api/csharp/aspire.hosting/imanifestexpressionprovider.md).
- `format` (`string?`) `optional`
  The format to be applied to the value. e.g., "uri"

## Exceptions

- `InvalidOperationException`

## AppendLiteral(string)

- Name: `AppendLiteral(string)`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/ReferenceExpression.cs#L338-L339)

Appends a literal value to the expression.

```csharp
public struct ExpressionInterpolatedStringHandler
{
    public readonly void AppendLiteral(
        string value)
    {
        // ...
    }
}
```

## Parameters

- `value` (`string`)
  The literal string value to be appended to the interpolated string.
