vendredi 7 juillet 2017

c# booleans: return true if first boolean is true and the second is false

I'm learning C# and have attempted this question. Please see my two attempts underneath the question below, and can someone point out to me where/how I have gone wrong please? Thanks.

Attempt 1:
Return true if the first boolean is true and the second is false.

public static bool ReturnTrueAndFalse(bool boolean1, bool boolean2)
{
    if (boolean1 = true && (boolean2 = false))
    {
        return true;
    }
    return false;
}

Attempt 2:

public static bool ReturnTrueAndFalse(bool boolean1, bool boolean2)
{
    boolean1 = true;
    boolean2 = false;
    return boolean1 && boolean2;
}

Aucun commentaire:

Enregistrer un commentaire