C# Comparison shorthand

Posted by TheAdamGaskins on Stack Overflow See other posts from Stack Overflow or by TheAdamGaskins
Published on 2011-01-17T23:58:09Z Indexed on 2011/01/18 1:53 UTC
Read the original article Hit count: 181

Filed under:
|
|

I have this code:

    if (y == a && y == b && y == c && y == d ...)
    {
        ...
    }

Is there some form of shorthand so that I can rewrite it as something like this?

    if(y == (a && b && c && d ...))
    {
        ...
    }

The functionality should be exactly the same. I'm just looking for something that looks less confusing.

EDIT Sorry for not clarifying, all the variables are integers. I'm looking for a shorter way to ensure that a, b, c, d, ... all equal y.

© Stack Overflow or respective owner

Related posts about c#

Related posts about comparison