Snippets of C# code

This is primarily intended as personal reminder, however, anyone who likes to can use them.
The code is provided as is, with no guarantee of correctness. Do not hold me liable if it does not work correctly in your application.
I'll be happy to collect code improvements; a new code is an improvement if:
- it does a better job;
- it does the same job but using fewer lines of simple code.

General algorithms