fork download
using System;
using System.Collections.Generic;


namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            Random rnd = new Random(123);

            LinkedList<int> list = new LinkedList<int>();
            for (int i = 0; i < 25; i++)
            {
                list.AddLast(rnd.Next(0, 5));
            }
            Console.WriteLine("До:");
            foreach (var i in list)
            {
                Console.WriteLine(i);
            }
            Console.WriteLine();
            LinkedListNode<int> node;
            node = list.First;
            while (node != null)
            {
                int prev = -9999;
                int next = -99;
                if (node.Previous != null)
                {
                    prev = node.Previous.Value;
                }
                if (node.Next != null)
                {
                    next = node.Next.Value;
                }
                var nextNode = node.Next;
                if (node.Value == prev || prev == next || node.Value == next)
                {
                    Console.WriteLine("DELETE: Prev:{0} ,Curr:{1}, Next:{2}", prev, node.Value, next);
                    //Удаление элемента
                    list.Remove(node);
                }
                node = nextNode;
            }

            Console.WriteLine();

            Console.WriteLine("После:");

            foreach (var i in list)
            {
                Console.WriteLine(i);
            }

            Console.ReadKey();
        }
    }
}
Success #stdin #stdout 0.04s 24264KB
stdin
Standard input is empty
stdout
До:
4
3
1
4
4
0
0
2
4
3
0
4
2
4
0
0
1
0
0
1
3
4
2
3
1

DELETE: Prev:1 ,Curr:4, Next:4
DELETE: Prev:4 ,Curr:0, Next:0
DELETE: Prev:4 ,Curr:2, Next:4
DELETE: Prev:4 ,Curr:4, Next:0
DELETE: Prev:4 ,Curr:0, Next:0
DELETE: Prev:0 ,Curr:1, Next:0
DELETE: Prev:0 ,Curr:0, Next:0
DELETE: Prev:0 ,Curr:0, Next:1

После:
4
3
1
4
0
2
4
3
0
4
0
1
3
4
2
3
1