C# removing duplicates in List<int>
<p>So my code is basically this:</p>

<p>List list = new List(new int[] { 1, 5, 8, 8, 8, 2, 3, 3, 4, });
        list = RemoveDuplicats(list);</p>

<pre><code>public static List&lt;int&gt; RemoveDuplicats(List&lt;int&gt; list)
{
   int i = 0;
   while (i&lt;list.Count)
      {
        if (list[i] == list[i+1])
          {
            list.RemoveAt(list[i + 1]);
            return list;
          }
          i++;
      }
    return list;
  }
</code></pre>

<p>It seems like RemoveAt is not working or it's being skipped entirely. So what i should be getting is 1,5,8,2,3,4 but it just prints original list. Where'd i go wrong?</p>