title: Removing a node from a LinkedList (C#)
body: <p>I created a <code>LinkedList</code> class with a function <code>delete</code> to remove a certain node from the list if found, however it's not working:</p>
  
  <pre><code>public class LinkedList
  {
      public Node head;
      &lt;...&gt;
      public void delete(string n)
      {
          Node x = search(n); //returns the node to delete or null if not found
          if (x != null)
              x = x.next;
      }
      &lt;...&gt;
  }
  </code></pre>
  
  <p>I figured all I needed to do is find the node and set it to the next one (so the node is "removed" out of the linked list), however it's not. If anyone could help me out it'd be much appreciated!</p>
  
  <p>EDIT: Forgot to mention I have a single linked list.</p>
  
  <p>EDIT2: My new code:</p>
  
  <pre><code>    public void delete(string n)
      {
          Node x = head;
          while (x != null &amp;&amp; x.name != n)
          {
              if (x.next.name == n)
                  x.next = x.next.next;
              x = x.next;
          }
          if (x != null)
              x = null;
      }
  </code></pre>