當前位置: 首頁>>代碼示例>>VB.NET>>正文


VB.NET LinkedListNode<T>類代碼示例

本文整理匯總了VB.NET中System.Collections.Generic.LinkedListNode<T>的典型用法代碼示例。如果您正苦於以下問題:VB.NET LinkedListNode<T>類的具體用法?VB.NET LinkedListNode<T>怎麽用?VB.NET LinkedListNode<T>使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了LinkedListNode<T>類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。

示例1: GenericCollection

' 導入命名空間
Imports System.Collections.Generic

Public Class GenericCollection

    Public Shared Sub Main()

        ' Create a new LinkedListNode of type String and displays its properties.
        Dim lln As New LinkedListNode(Of String)("orange")
        Console.WriteLine("After creating the node ....")
        DisplayProperties(lln)

        ' Create a new LinkedList.
        Dim ll As New LinkedList(Of String)

        ' Add the "orange" node and display its properties.
        ll.AddLast(lln)
        Console.WriteLine("After adding the node to the empty LinkedList ....")
        DisplayProperties(lln)

        ' Add nodes before and after the "orange" node and display the "orange" node's properties.
        ll.AddFirst("red")
        ll.AddLast("yellow")
        Console.WriteLine("After adding red and yellow ....")
        DisplayProperties(lln)

    End Sub

    Public Shared Sub DisplayProperties(lln As LinkedListNode(Of String))

        If lln.List Is Nothing Then
            Console.WriteLine("   Node is not linked.")
        Else
            Console.WriteLine("   Node belongs to a linked list with {0} elements.", lln.List.Count)
        End If 

        If lln.Previous Is Nothing Then
            Console.WriteLine("   Previous node is null.")
        Else
            Console.WriteLine("   Value of previous node: {0}", lln.Previous.Value)
        End If 

        Console.WriteLine("   Value of current node:  {0}", lln.Value)
        
        If lln.Next Is Nothing Then
            Console.WriteLine("   Next node is null.")
        Else
            Console.WriteLine("   Value of next node:     {0}", lln.Next.Value)
        End If 

        Console.WriteLine()

    End Sub

End Class
開發者ID:VB.NET開發者,項目名稱:System.Collections.Generic,代碼行數:55,代碼來源:LinkedListNode

輸出:

After creating the node ....
Node is not linked.
Previous node is null.
Value of current node:  orange
Next node is null.

After adding the node to the empty LinkedList ....
Node belongs to a linked list with 1 elements.
Previous node is null.
Value of current node:  orange
Next node is null.

After adding red and yellow ....
Node belongs to a linked list with 3 elements.
Value of previous node: red
Value of current node:  orange
Value of next node:     yellow


注:本文中的System.Collections.Generic.LinkedListNode<T>類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。