why not just 
```
if (gender != S.gender)
```