Remove element from LinkedList by value (C#)
<p>I'm trying to remove a Node from LinkedList by it's value however it doesn't seem to work.
LinkedList class (with node):</p>

<pre><code>public class Node&lt;T&gt;
    {
        private T info;
        private Node&lt;T&gt; next;

        public Node(T x, Node&lt;T&gt; next)
        {
            this.info = x;
            this.next = next;
        }

        public Node&lt;T&gt; GetNext()
        {
            return this.next;
        }

        public void SetNext(Node&lt;T&gt; next)
        {
            this.next = next;
        }

        public T GetInfo()
        {
            return this.info;
        }

        public void SetInfo(T x)
        {
            this.info = x;
        }

        public override string ToString()
        {
            return this.info.ToString();
        }
    }

    public class List&lt;T&gt;
    {

        private Node&lt;T&gt; first;

        public List()
        {
            this.first = null;
        }

        public Node&lt;T&gt; GetFirst()
        {
            return this.first;
        }

        public Node&lt;T&gt; Add(Node&lt;T&gt; pos, T x)
        {
            Node&lt;T&gt; temp = new Node&lt;T&gt;(x, null);

            if (pos == null)
            {
                temp.SetNext(this.first);
                this.first = temp;
            }
            else
            {
                temp.SetNext(pos.GetNext());
                pos.SetNext(temp);
            }

            return temp;
        }

        public Node&lt;T&gt; Remove(Node&lt;T&gt; pos)
        {
            if (this.first == pos)
                this.first = pos.GetNext();
            else
            {
                Node&lt;T&gt; prevPos = this.GetFirst();
                while (prevPos.GetNext() != pos)
                    prevPos = prevPos.GetNext();
                prevPos.SetNext(pos.GetNext());
            }

            Node&lt;T&gt; nextPos = pos.GetNext();
            pos.SetNext(null);

            return nextPos;
        }


        public override string ToString()
        {
            string str = "[";
            Node&lt;T&gt; pos = this.first;
            while (pos != null)
            {
                str += pos.GetInfo().ToString();
                if (pos.GetNext() != null)
                    str += ", ";
                pos = pos.GetNext();
            }

            str += "]";

            return str;
        }
    }
</code></pre>

<p>That's the function:</p>

<pre><code>public void Del(string info)
        {
            Node&lt;T&gt; previousNode = null, obsoleteNode = null, nextNode = null;
            Node&lt;T&gt; pos = this.first;
            while (pos != null)
            {
                if (pos == this.first &amp;&amp; this.first.GetInfo().ToString() == info)
                {
                    Node&lt;T&gt; temp = pos;
                    this.first = this.first.GetNext();
                    temp = null;
                }
                else
                {
                    previousNode = pos;
                    if (previousNode != null)
                        obsoleteNode = previousNode.GetNext();
                    if (nextNode == null)
                        nextNode = pos.GetNext().GetNext();
                    if (obsoleteNode != null)
                    {
                        if (obsoleteNode.GetInfo().ToString() == info)
                            previousNode.SetNext(nextNode);
                    }
                }
                pos = pos.GetNext();
            }

        }
</code></pre>

<p>In VS autos it shows that obsoleteNode is actually null but i can't understand why.
All other values are okay, except pos, it gets somehow the last node in the list instead of first but the this.first himself is okay.
What can be the problem?</p>
