1
我不知道該怎麼解釋這一點,我想下面的方法來工作,但它給了我錯誤說泛型幫助需要
的
as' operator cannot be used with a non-reference type parameter
T」。考慮添加`class'或引用類型約束。
任何人都可以幫我解決這個問題嗎?
public T GetRoot<T>() {
if (this is T)
return this as T;
if (parent != null)
return parent.GetRoot<T>();
return null;
}