Rewrite of Chaos% in C#