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:
pepaskopec-blip 2026-10-11 14:37:14 +02:00
commit 333085ee53
86 changed files with 2482 additions and 5 deletions

View file

@ -0,0 +1,37 @@
---
id: cs-4-generika
nazev: Generika
popis: Jedna metoda pro víc typů.
---
# Výklad
## T
*typový parametr*
- static void Vypis<T>(T hodnota) přijme int i string.
- T se doplní při volání podle argumentu.
- Jedna metoda tak nenutí kopírovat kód pro každý typ.
> Tip: Když metoda s T má umět jen porovnávat, T se omezí. Tady stačí výpis.
## List
*už ho znáte*
- List<string> je generická třída. string je dosazený T.
- Stejný List<int> drží čísla a metody jsou stejné.
- Generika hlídá typ. Do List<int> string nedáte.
> Tip: Zavolejte Vypis s číslem i s textem.
# Kód
```
Vypis(7);
Vypis("ahoj");
static void Vypis<T>(T hodnota)
{
Console.WriteLine(hodnota);
}
```