while (currentNode?.BinaryComp(_value) != null);
public static bool operator !=(Node<T> f1, Node<T> f2)
{
return f1.Value.CompareTo(f2.Value) != 0;
}
System.NullReferenceException:
while (currentNode?.BinaryComp(_value) != null);
public static bool operator !=(Node<T> f1, Node<T> f2)
{
return f1.Value.CompareTo(f2.Value) != 0;
}
System.NullReferenceException:
You can use ReferenceEquals. Also, if f1 or f2 is null, then f1.Value will throw an exception. Either use, f1?.Value or use referenceequals.
Your code should look something like this:
public static bool operator !=(Node<T> f1, Node<T> f2)
{
if (object.ReferenceEquals(f1, null))
{
return object.ReferenceEquals(f2, null);
}
return f1.Value.CompareTo(f2.Value);
}
Here is an interesting article on Equals, ==, ReferenceEquals