Solution for some coding exercises in C#