# IResourceCollection Methods

- Package: [Aspire.Hosting](/reference/api/csharp/aspire.hosting.md)
- Type: [IResourceCollection](/reference/api/csharp/aspire.hosting/iresourcecollection.md)
- Kind: `Methods`
- Members: `1`

Represents a collection of resources.

## TryGetByName(string, IResource?)

- Name: `TryGetByName(string, IResource?)`
- Modifiers: `virtual`
- Returns: `bool`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/IResourceCollection.cs#L24-L35)

Attempts to find a resource by its name.

```csharp
public interface IResourceCollection
{
    public virtual bool TryGetByName(
        string name,
        out IResource? resource)
    {
        // ...
    }
}
```

## Parameters

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

## Returns

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

## Remarks

The resource name comparison is case-insensitive.
