# InteractionInputCollection Methods

- Package: [Aspire.Hosting](/reference/api/csharp/aspire.hosting.md)
- Type: [InteractionInputCollection](/reference/api/csharp/aspire.hosting/interactioninputcollection.md)
- Kind: `Methods`
- Members: `3`

A collection of interaction inputs that supports both indexed and name-based access.

## ContainsName(string)

- Name: `ContainsName(string)`
- Returns: `bool`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/IInteractionService.cs#L428)

Determines whether the collection contains an input with the specified name.

```csharp
public sealed class InteractionInputCollection
{
    public bool ContainsName(
        string name)
    {
        // ...
    }
}
```

## Parameters

- `name` (`string`)
  The name to locate in the collection.

## Returns

`bool` -- true if the collection contains an input with the specified name; otherwise, false.

## GetEnumerator

- Name: `GetEnumerator`
- Returns: [IEnumerator<InteractionInput>](/reference/api/csharp/aspire.hosting/interactioninput.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/IInteractionService.cs#L440)

Returns an enumerator that iterates through the collection.

```csharp
public sealed class InteractionInputCollection
{
    public IEnumerator<InteractionInput> GetEnumerator()
    {
        // ...
    }
}
```

## Returns

[IEnumerator<InteractionInput>](/reference/api/csharp/aspire.hosting/interactioninput.md) -- An enumerator that can be used to iterate through the collection.

## TryGetByName(string, InteractionInput?)

- Name: `TryGetByName(string, InteractionInput?)`
- Returns: `bool`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/IInteractionService.cs#L418)

Tries to get an input by its name.

```csharp
public sealed class InteractionInputCollection
{
    public bool TryGetByName(
        string name,
        out InteractionInput? input)
    {
        // ...
    }
}
```

## Parameters

- `name` (`string`)
  The name of the input.
- `input` ([InteractionInput?](/reference/api/csharp/aspire.hosting/interactioninput.md))
  When this method returns, contains the input with the specified name, if found; otherwise, null.

## Returns

`bool` -- true if an input with the specified name was found; otherwise, false.
