# “YieldExceptionYield” (Solution)

## Answer

Exception is not going to happen.

## Explanation

Indeed, the line

```csharp
var numbers = GetSmallNumbers();
```

is only building a query, but does not execute it. The line

```csharp
var evenNumbers = numbers.Select(n => n * 2);
```

is also only building another query without direct execution. Let's look to the last list of the `Main` method:

```csharp
Console.WriteLine(evenNumbers.FirstOrDefault());
```

This call will get only the first element of the result enumerable (single call of `MoveNext()` and `Current` will be executed). Evaluation of the next elements will nor occur. Thus, the code will work without any exceptions.

[Problem](/problembookdotnet/en/linq/yieldexceptionyield-p.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://andreyakinshin.gitbook.io/problembookdotnet/en/linq/yieldexceptionyield-s.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
