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
38
content/programovani/2-rocnik/08-navrat.md
Normal file
38
content/programovani/2-rocnik/08-navrat.md
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
---
|
||||
id: cs-2-navrat
|
||||
nazev: Parametry a návrat
|
||||
popis: Metoda dostane hodnoty a může jednu vrátit.
|
||||
---
|
||||
|
||||
# Výklad
|
||||
|
||||
## Parametr
|
||||
*vstup*
|
||||
|
||||
- int a v závorce je parametr. Volající dodá argument.
|
||||
- Součet(2, 5) uloží 2 do a a 5 do b.
|
||||
- Jména parametrů platí jen uvnitř metody.
|
||||
|
||||
> Tip: Změňte argumenty a výsledek se změní, metoda ne.
|
||||
|
||||
## return
|
||||
*výstup*
|
||||
|
||||
- int před jménem je typ výsledku.
|
||||
- return hodnotu vrátí a metodu ukončí.
|
||||
- Volající si výsledek může uložit: int s = Soucet(2, 5);
|
||||
|
||||
> Tip: return 0 omylem na začátku by zbytek metody nespustil.
|
||||
|
||||
# Kód
|
||||
|
||||
```
|
||||
int s = Soucet(2, 5);
|
||||
Console.WriteLine(s);
|
||||
Console.WriteLine(Soucet(10, 1));
|
||||
|
||||
static int Soucet(int a, int b)
|
||||
{
|
||||
return a + b;
|
||||
}
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue