C# AND Operator, how can this be true?
I get the AND operator most of the time. But not in this case. In the c# course, Logical Operators. At the first page they talk about AND Operator. Here they also show that only when BOTH are true, the result is true. However in their last question they ask: " If a is true and b is false, what is the result of !(a&&b)? " And that result is true. But how? First you say that BOTH needs to be true in order for the result to be true. And now when one of the statements is false. We still get true?? Again in the picture it says that it should have been false. for example: int childone = 18; int childtwo = 14; if ( !(childone >17 && childtwo >17)) { Console.WriteLine("Both are older then 17"); } So in my example. First child one is older then 17 so thats true. And child two is not older then 17 so its false. Then we switch that around with the NOT operator. Should we not get childone <17 and childtwo <17?? Which is false and true. And that should give us again a result of false cause they are not both younger then 17. ( childone is still 18 ) Maybe someone can help me out with this one. Would be nice if i could understand the logic behind this.