這是一個函數,應該採取一個列表並將其逆轉。我不知道爲什麼我得到這個錯誤。爲什麼我會得到:「錯誤t 2參數1:無法從'int'轉換爲'TRAINING1.Node <int>''錯誤?
public static void What(List<int> lst)
{
Stack<int> st1 = new Stack<int>();
while (!lst.IsEmpty())
{
**st1.Push(lst.Remove(lst.GetFirst().GetInfo());**
}
Node<int> pos = lst.GetFirst();
while (!st1.IsEmpty())
{
pos = lst.Insert(pos, st1.Pop());
}
}
.GetInfo()返回什麼? – RQDQ
什麼是方法:GetFirst()和.GetInfo()? - 我假設他們不返回一個整數? –
您將pos作爲第一個參數傳遞給lst.Insert方法。這個論點應該是一個int,而不是一個節點這是什麼pos。 –