Home > Back-end >  Could someone explain to me what is returned in this if statement
Could someone explain to me what is returned in this if statement

Time:09-29

public void OnPressHigher()
    {
       if (min >= max || guess == max) return;
        min = guess   1;
        NextGuess();
    }

I can't figure out what is returned in this if statement.

CodePudding user response:

There is nothing returned because your functions return type is void. In the context in your code it means that if the condition min >= max || guess == max isn't met, the function shouldn't continue to execute and should return to it's caller.

CodePudding user response:

The method is declared as returning void

public void OnPressHigher()

Which means it will never return anything. Therefore, a return instruction will simply exit the method at that point and not execute any further instructions within the method.

  •  Tags:  
  • c#
  • Related