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
34
content/programovani/4-rocnik/07-delegaty.md
Normal file
34
content/programovani/4-rocnik/07-delegaty.md
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
---
|
||||
id: cs-4-delegaty
|
||||
nazev: Delegáty
|
||||
popis: Proměnná, do které uložíte metodu.
|
||||
---
|
||||
|
||||
# Výklad
|
||||
|
||||
## Func
|
||||
*funkce*
|
||||
|
||||
- Func<int, int> je metoda, která dostane int a vrátí int.
|
||||
- x => x * x je taková metoda bez jména.
|
||||
- Do proměnné ji uložíte a zavoláte později.
|
||||
|
||||
> Tip: Závorky pocet(4) metodu spustí. Bez nich byste ji jen předali dál.
|
||||
|
||||
## Action
|
||||
*bez výsledku*
|
||||
|
||||
- Action nic nevrací. Hodí se na kroky.
|
||||
- Metodu můžete předat jiné metodě jako argument.
|
||||
- Tak se píše i Where z minulé lekce.
|
||||
|
||||
> Tip: Vyměňte x * x za x + 1.
|
||||
|
||||
# Kód
|
||||
|
||||
```
|
||||
Func<int, int> pocet = x => x * x;
|
||||
Console.WriteLine(pocet(4));
|
||||
Action pozdrav = () => Console.WriteLine("ahoj");
|
||||
pozdrav();
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue