Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# C# Objects Methods Statements

beginner bool question

public bool IsCorrect(int x) { return (x > 2 && x < 5) || (x == 10); }

how is the return value TRUE if 10 is greater than 2 and 5 is geater than 10? my logic stopped working

2 Answers

Steven Parker
Steven Parker
229,732 Points

What makes this true when the value is 10 is the last expression (x == 10) which is then combined with the other expression using the "or" operator ( || ), which gives a true result if either operand is true.

Thank you very much