Reputation: 2878
Is there an operator in c# for checking if more than one value matches, for example to simplify this:
if (a == b && b == c)
To become something like this, which is invalid
if (a == b == c)
Just curious more than anything.
Upvotes: 1
Views: 487
Reputation: 1501163
No, there isn't. (And personally I'm glad there isn't. This is useful in a relatively rare number of cases, and the additional language complexity required to support it would be significant.) You could write your own method for this if you use it very frequently, but otherwise, just use the first form.
Note that the code you've already got would compile if a
, b
and c
are bool
variables, but wouldn't do what you want.
Upvotes: 7