Em hiện nay đang port 1 chương trình từ C sang C# thì gặp lỗi sau ạ , đây là phần Code
Tree Search(Tree root, char str[]) {
if (root == NULL) return NULL;
//Tim tham tu thi tra ve tu
if (strcmp(root->Word, str) == 0) return root;
//Tim Node ben trai
Tree p = Search(root->Left, str);
if (p != NULL) return p;
//Tim Node ben phai
Tree q = Search(root->Right, str);
if (q != NULL) return q;
}
Còn đây là phần code bên C# và lỗi (theo em hiểu thì phải thêm 1 câu return khác vào cuối thì mới hết lỗi nhưng làm vậy thì kết quả chương trình sẽ sai)
static Tree Search(Tree root, string Word)
{
if (root == null) return null;
if (String.Compare(root.Word, Word) == 0) return root;
Tree p = Search(root.Left, Word);
if (p != null) return p;
Tree q = Search(root.Right, Word);
if (q != null) return q;
}
Thông báo lỗi:
CS0161 'Program.Search(Tree, string)': not all code paths return a value
Làm sao để fix lỗi này ạ ? Em xin cảm ơn