porting to csharp