Convert to C#

Converted to C# + testform