I have 2 type object variables that need to be compared using a dynamic enumeration-based operation:
public enum OperationType { None, EqualTo, NotEqualTo, GreaterThan, GreaterThanOrEqualTo, LessThan, LessThanOrEqualTo }
You can make the assumption that the basic type of variables is the same, it can only be of type string or any other type of value, but it is unknown at design time.
I currently have the following:
bool match; switch (Operation) { case OperationType.EqualTo: match = Equals(targetValue, valueToMatch); break; case OperationType.NotEqualTo: match = Equals(targetValue, valueToMatch) == false; break; case OperationType.GreaterThan: //?? break; case OperationType.GreaterThanOrEqualTo: //?? break; case OperationType.LessThan: //?? break; case OperationType.LessThanOrEqualTo: //?? break; default: throw new ArgumentOutOfRangeException(); }
What is the best way to determine compliance at runtime (C # 4.0)?
source share