簡體   English   中英

如何將通用 class object 作為參考傳遞給另一種方法?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM