Attempted conversion to C#