Why does this return False
public enum Directions { Up, Down, Left, Right }
static void Main(string[] args)
{
bool matches = IsOneOf(Directions.Right, Directions.Left, Directions.Right);
Console.WriteLine(matches);
Console.Read();
}
public static bool IsOneOf(Enum self, params Enum[] values)
{
foreach (var value in values)
if (self == value)
return true;
return false;
}
while this returns True?
public static bool IsOneOf(Enum self, params Enum[] values)
{
foreach (var value in values)
if (self.Equals(value))
return true;
return false;
}