Aaron Thomas Aaron Thomas - 1 month ago 5x
C# Question

Multiple comparison operators

What is the standard way in C# to check if a number is within a range of numbers?

Typically, I would do some variation of this with int


return (i >= start && i <= end);

Is there no syntax for something like this:

// does not work
return (start <= i <= end);


The most close to what you expect is

return start <= i && i <= end;