mirror of
https://github.com/pepaskopec-blip/Graduately.git
synced 2026-10-27 15:14:35 +00:00
Add a C# course with a side-by-side code runner.
Each lesson explains a topic and runs the edited program next to the text through the local .NET SDK. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
6662eb185e
commit
333085ee53
86 changed files with 2482 additions and 5 deletions
36
content/programovani/4-rocnik/04-linq.md
Normal file
36
content/programovani/4-rocnik/04-linq.md
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
---
|
||||
id: cs-4-linq
|
||||
nazev: LINQ
|
||||
popis: Dotazy nad seznamem.
|
||||
---
|
||||
|
||||
# Výklad
|
||||
|
||||
## Where
|
||||
*filtr*
|
||||
|
||||
- Where nechá jen prvky, které splní podmínku.
|
||||
- n => n >= 10 je krátká funkce: vezmi n a vrať, jestli je aspoň 10.
|
||||
- Samotné Where ještě nic neprojde. ToList nebo foreach výsledek vezme.
|
||||
|
||||
> Tip: Šipka => není porovnání. Je to zápis malé funkce.
|
||||
|
||||
## Select
|
||||
*převod*
|
||||
|
||||
- Select z každého prvku udělá jiný.
|
||||
- OrderBy seřadí.
|
||||
- Dotaz lze řetězit: Where a pak Select.
|
||||
|
||||
> Tip: Změňte 10 na 12 a dvojka z výpisu zmizí.
|
||||
|
||||
# Kód
|
||||
|
||||
```
|
||||
int[] cisla = { 4, 11, 7, 20 };
|
||||
var velka = cisla.Where(n => n >= 10).OrderBy(n => n);
|
||||
foreach (int n in velka)
|
||||
{
|
||||
Console.WriteLine(n);
|
||||
}
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue