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/1-rocnik/08-vstup.md
Normal file
34
content/programovani/1-rocnik/08-vstup.md
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
---
|
||||
id: cs-1-vstup
|
||||
nazev: Vstup z konzole
|
||||
popis: Console.ReadLine přečte řádek.
|
||||
---
|
||||
|
||||
# Výklad
|
||||
|
||||
## ReadLine
|
||||
*text*
|
||||
|
||||
- ReadLine počká na řádek a vrátí ho jako string.
|
||||
- V této lekci řádek napište do pole Vstup a pak Spustit.
|
||||
- Každé další ReadLine vezme další řádek vstupu.
|
||||
|
||||
> Tip: Když vstup necháte prázdný, ReadLine dostane konec a program může spadnout.
|
||||
|
||||
## Číslo ze vstupu
|
||||
*Parse*
|
||||
|
||||
- ReadLine nikdy nevrací int. Vrací text.
|
||||
- int.Parse z něj číslo udělá.
|
||||
- Napište do vstupu třeba 17.
|
||||
|
||||
> Tip: Zkuste ve vstupu Anna a uvidíte chybu. Parse čeká číslo.
|
||||
|
||||
# Kód
|
||||
|
||||
```
|
||||
Console.WriteLine("Kolik ti je?");
|
||||
string radek = Console.ReadLine();
|
||||
int vek = int.Parse(radek);
|
||||
Console.WriteLine($"Za rok ti bude {vek + 1}.");
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue