in operator check if the left-hand value side is in the Array and Collections, Set or Flags Enum on the right, and returns
var x: set of Color;
if Color.Red in x then
For Set and Flags Enum types, the operartor directly checks whether the value is included. For Flags, that is the equivalent of applying the
and bitwise operator and checking for equality.
For Arrays, Collections and Sequences, the
in operator invokes the LINQ
Contains method, if available.
For ease of readability, the
in operatore can be combined with
not, to negate the result.
if Color.Red not in x then
Which is more naturally readable than the equivalent:
if not (Color.Red in x) then