Csharp sample code
Here is some sample code for different parts of the C# course:
Basics (
gitlab repo with all samples here
):
C# Hello World
enums sample
(exercise0.cs)
double sample
command-line input sample
(based on double)
loops sample
array samples
nullable types
functions samples
Sample solutions:
Sample solution for Exercises 3a and 3b (on enumerations)
Sample solution of Binary Search Tree (with generics, delegates and enumerator)
Objects:
Points (public)
,
Points (private)
,
Points (properties)
Person object
File I/O: (see
these slides
)
File hello world
File I/O sample
Database interfaces:
LINQ interface
MySQL interface
Advanced C#: (see
these slides
and
4up
version)
Container
Delegates
Delegates
Indexers
Binary Search Trees
Case study on Delegates and Generics (see
these slides
):
Quicksort with Delegates
Quicksort with Delegates and Generics
Code Contract Samples: (see
these slides
)
CodeContractSample0.cs
RationalsWithCodeContracts.cs
FunctionsWithCodeContracts.cs
Min3WithCodeContracts.cs
exercise4aWithCodeContracts.cs
Regular Expressions: (see
these slides
)
regexp1.cs
regexp4.cs
Threading: (see
these slides
and
this online Tutorial
)
Multi-threaded swap
Incrementer/Decrementer Example
Incrementer/Decrementer Example with marks
Expanded multi-threading example
Background worker example
ContinueWith example
async example
Serialisation and Reflection (see
these slides
):
Implicit Serialisation
Reflection-based Serialisation
Custom Attributes
System Programming in C#: (see
these slides
and
4up
version)
Linked list
unsafe code sample
unsafe swap
memcpy
memcpy with wrapper
Interfacing to C:
sumWrapper.cs
,
sum.c
ListReversal1.cs (copying reversal of a single-linked list)
ListReversal2.cs (in-place reversal of a single-linked list)
C# Revision: (see
these slides
and
4up
version))
C# revision (extended bank account example)
C# revision including Code Contract examples
C# 6.0 features
(see also
The New and Improved C# 6.0
)
Parallel Programming in C#: (see
these slides
)
Parallel For Loops
,
with aggregates
,
with partitioners
Parallel Tree mapper
Futures
Parallel pipeline
Parallel Quicksort
Parallel Goldbach conjecture
Hans-Wolfgang Loidl
Last modified: Mon Oct 19 16:59:41 2015