Aaron Thomas Aaron Thomas - 7 months ago 69
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;