Hi,
I found this:
if ((value | 6 | 8 | 10) == (6 | 8 | 10) && value != 0)
{
size1 = value;
}
In this case, there's no many difference in length of your condition. If you've variables with long names, or if many options are possible, this is a shorter condition.
Alternatively, you can write an
extension method[
^] for
object
s:
public static class MultipleOrConditionClass
{
public static bool MultipleOrCondition(this object obj, params object[] objectsToCompare)
{
return objectsToCompare.Contains(obj);
}
}
Now, use this condition:
if (value.MultipleOrCondition(6, 8, 10))
{
size1 = value;
}
Hope this helps.