> For the complete documentation index, see [llms.txt](https://apwt.gitbook.io/zie-scherp-scherper/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://apwt.gitbook.io/zie-scherp-scherper/coding-guidelines/linq.md).

# Minpunten voor: Linq gebruiken

*(-3 punten)*

Zonder in detail te gaan, weet dat je bij arrays dankzij Linq een aantal handige methoden hebt die je niet mag gebruiken. Dit jaar moet je al je bewerkingen op arrays manueel m.b.v. loops doen.

Zijn dus **niet toegestaan** ([bron](https://www.completecsharptutorial.com/linqtutorial/linq-average-count-max-sum-first-contains-elementat-distinct-example-csharp.php#:~:text=Average\(\)%20%2D%20Average%20Method%20calculates,numeric%20values%20from%20the%20list)):

* `Average()` - Average Method calculates the average value of numeric data.
* `Count()` – Count method count the present items in list.
* `Max()` – It picks the maximum numeric values from the list.
* `Min()` – It picks the minimum numeric values from the list.
* `Sum()` – It calculates the sum of total numeric value present in the list.
* `First()` – It picks the first value present in the list.
* `Last()` – It picks the last value present in the list.
* `Contains()` – It find the value in the list and returns Boolean (true/false) result.
* `ElementAt()` – It picks the value from the list on the given position.
* `Distinct()` – It removes duplicate value and picks only unique elements.

Opgelet: de [Array. methoden zoals IndexOf, Fill etc. zijn wél toegestaan](https://learn.microsoft.com/en-us/dotnet/api/system.array?view=net-8.0).

## Uitgewerkt voorbeeld

In de opgave staat "bereken het gemiddelde van de waarden in de array `leeftijden`. Dan is volgende oplossing **niet** toegestaan:

```csharp
double gemiddelde = leeftijden.Average();
```

De juiste oplossing is dan wel:

```csharp
double som=0;
for(int i = 0; i < leeftijden.Length; i++)
{
    som+= leeftijden[i];
}
double gemiddelde = som/leeftijden.Length;
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://apwt.gitbook.io/zie-scherp-scherper/coding-guidelines/linq.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
