尝试用链表实现堆栈,在pop中出现问题,代码
public class MyItemType
{
................
}
class MyStack
{
LinkedList<MyItemType> ourList = null;
MyItemType top = null;
................
public MyItemType Pop()
{
if (IsEmpty())
{
return null;
}
else
{
MyItemType temp = ourList.Last; // <--- issue here
ourList.RemoveLast();
return temp;
}
}
................
}
错误:错误2不能隐式转换类型"System.Collections.Generic"。LinkedListNode' to 'Ex1。MyItemType '
你需要这样做
ourList.Last.Value
文档