How to find the previous and next nodes of specific node in LinkedList with C#

1 Answer

0 votes
using System;
using System.Collections.Generic;
                       
public class Program
{
    public static void Main()
    {
        string[] arr =  { "python", "c#", "php", "nodejs", "java", "c", "c++" };
           
        LinkedList<string> ll = new LinkedList<string>(arr);
         
        LinkedListNode<string> current = ll.Find("php");
           
        Console.WriteLine(current.Previous.Value);
        Console.WriteLine(current.Next.Value);
    }
}
   
 
 
/*
run:
 
c#
nodejs
 
*/

 



answered May 7, 2020 by avibootz

Related questions

...