converted to c#