链表参考
我正在尝试将一个元素插入到 C# 中的链接列表中。我收到 invaliderOperationException 因为我认为我没有对实际链接列表节点的引用。
private static LinkedList<ScoreNode> scores;
private static LinkedListNode<ScoreNode> posNode;
当前我将posNode设置为scores中满足一定条件的元素 然后我使用 AddBefore 方法在 posNode 之前添加一个新的 LinkedListNode(ScoreNode)。 所以如果我是正确的,我认为我得到了异常,因为内存中 posNode 之前没有存储任何内容。那么我怎样才能从分数中的元素获取参考呢?
I am trying to insert an element into a linked list in c#. I get an invaliderOperationException because I think I do not have a reference to the actually linked-list-node.
private static LinkedList<ScoreNode> scores;
private static LinkedListNode<ScoreNode> posNode;
Current I set posNode to the element in scores that satisfies a certain condition
then I use the AddBefore method to add a new LinkedListNode(ScoreNode) before posNode.
So if I am correct, I think that I get the exception because there is nothing stored before posNode in memory. So how could i get a reference from an element in scores?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你初始化了吗?
Did you initialize it?