vendredi 22 juillet 2016

C# Returning a bool with a method

This is an extremely beginner question so I half apologise in advance before asking this! Hopefully the thumb downs won't be too brutal! I've already searched for an answer but didn't find anything already posted and the book I'm reading doesn't clarify.

I understand that return ends a method.

I've created a bool method with an if statement.

private bool isHappy()
{
    if (...)
    {
        return true;
    }

    return false;
}

When the if statement condition is met, does the method end and return the bool as true? Or does the method continue after the if statement and return false anyway? I'm tilting towards the former but would appreciate confirmation from the experts! Any help is greatly appreciated.

Aucun commentaire:

Enregistrer un commentaire