Translated CodeCrap code to C#