C# Demo Examples

Practice programs, one file each. Open a file in the code viewer, download it, modify it, and run it with dotnet run. Organized by lesson category.

How to use: click View to open a file in the code viewer, read its comments, download it, and run it in your own project with dotnet run. Each file is self-sufficient — no hidden dependencies.

Foundations

Syntax, variables, operators, control flow, loops, and methods.

#DescriptionLink
1Hello, WorldView
2Variables & TypesView
3OperatorsView
4Control FlowView
5LoopsView
6MethodsView

Composite & Collections

Structs, classes, records, arrays, and generic collections.

#DescriptionLink
7StructView
8ClassView
9RecordView
10ArraysView
11List<T>View
12DictionaryView

I/O & Files

Console interaction and text file handling.

#DescriptionLink
13Console I/OView
14FilesView

Reliability

Error handling, casting, and strings.

#DescriptionLink
15Error HandlingView
16String FunctionsView