Completed CSharp solution