[英]How to pass generic class object as ref to another method?
我正在嘗試將 AVLTree object 引用傳遞給另一種方法。
AVLTree 的定義 class => class AVLTree: IComparable> 其中 T: IComparable
代碼
Addhere(ref AVLTree<T> currentNode); //Passing like this
public void Addhere(ref AVLTree<T> currentNode) //Receiving like this
{
}
錯誤是 =>“使用泛型 AVLTree(T) 需要 1 個參數”
您需要在外面聲明並通過
AVLTree<T> currentnode = null; Addhere(ref currentnode);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.