Convert C code to C#

In Progress