# The new features in .NET 9 (C# 13)

### Index Method

```csharp
foreach ((int index, Product product) in ProductList.Products.Index())
{
    Console.WriteLine($"Index = {index}, Name = {product.Title}");
}
```

### SearchValues (This feature was introduced in .NET 8)

In .NET 8, the SearchValues type is limited to searching by characters. However, in .NET 9, it is possible to search by multiple strings.

```csharp
ReadOnlySpan<string> searchWords = ["dummy", "text", "and"];
SearchValues<string> searchValues =
    SearchValues.Create(searchWords, StringComparison.OrdinalIgnoreCase);

var searchString =
    """
    Lorem Ipsum is simply dummy text of
    the printing and typesetting industry.
    """;

var index = searchString
    .AsSpan()
    .IndexOfAny(searchValues);
```

```csharp
string[] productTitles = ProductList.Products.Select(x => x.Title).ToArray();

SearchValues<string> svProducts = SearchValues.Create(productTitles, StringComparison.OrdinalIgnoreCase);

IEnumerable<Product> found = ProductList.Products
    .Where(x => svProducts.Contains(x.Title));
```

The downside is you can not use the type Product, only the string.
