Fixed CS0019 Error - Cannot assume type T is a reference type but instead can infer that a default node can mean that the tree is empty

This commit is contained in:
Luke Else 2022-04-12 16:03:10 +01:00
parent 702b251a8a
commit 3f97e4b770

View File

@ -44,17 +44,16 @@ namespace C_.Datastructures.BinarySearchTree
//Insert to right //Insert to right
node.Right = TreeNode<T>.Create(value); node.Right = TreeNode<T>.Create(value);
return; return;
} }
public bool Find(T? value){ public bool Find(T? value){
if (Root.Value != default || Root.Value == value) if (Root == default)
{ {
} }
} }
private TreeNode<T>? Descend(T value, TreeNode<T>? current) private TreeNode<T>? Descend(T value, TreeNode<T>? current)
{//Keep trying to determine whether to go left or right until null node is found that can be appended to {//Keep trying to determine whether to go left or right until null node is found that can be appended to
if (current == default) if (current == default)