if statement and scopes - C#