I think, that ```tostring``` conversion is useless. You can check return value directly in
```
if( GetPortNumber( ...))
```