What would be the best way to determine if an object equals number zero (0) or string.empty in C#?
EDIT: The object can equal any built-in System.Value type or reference type.
Source Code:
public void MyMethod(object input1, object input2) { bool result = false; object compare = new object(); if(input != null && input2 != null) { if(input1 is IComparable && input2 is IComparable) { //do check for zero or string.empty //if input1 equals to zero or string.empty result = object.Equals(input2); //if input1 not equals to zero or string.empty result = object.Equals(input1) && object.Equals(input2); //yes not valid, but this is what I want to accomplish } } }
Using Jonathan Holland code sample with a minor modification, here is the solution that worked: