【发布时间】:2016-02-08 21:43:19
【问题描述】:
如何在不使用tail的情况下通过索引插入通用链表。
public void RemoveByIndex(int index)
{
int count = 0;
LinkedListNode<T> current = Head;
while (count <= index)
{
if (count == index)
{
current.Next = null;
}
else
{
current = current.Next;
}
count++;
}
Head = current;
}
我有数据 5、10、15 的 int 列表数组。我不知道为什么当我给他第一个索引时它总是删除我 5,15。
【问题讨论】:
-
当您实际从列表中删除时,为什么标题会显示“添加”?
-
已编辑,抱歉,今天的代码太多了。
标签: c# generics collections linked-list