Move the first node to be the last node : LinkedList « Data Structure « VB.Net






Move the first node to be the last node

 

Imports System
Imports System.Text
Imports System.Collections.Generic
Public Class Example

    Public Shared Sub Main()
        Dim words() As String = {"the", "fox", "jumped", "over", "the", "dog"}
        Dim sentence As New LinkedList(Of String)(words)

        Dim mark1 As LinkedListNode(Of String) = sentence.First
        sentence.RemoveFirst()
        sentence.AddLast(mark1)
        Display(sentence)

    End Sub

    Private Shared Sub Display(ByVal words As LinkedList(Of String))
        For Each word As String In words
            Console.Write((word + " "))
        Next
    End Sub

End Class

   
  








Related examples in the same category

1.LinkedList(T) Class represents a doubly linked list.
2.Create LinkedList of String from String array
3.Add the word to the beginning of the linked list.
4.Change the last node
5.Remove first and Find last