当前位置: 首页>>代码示例>>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;未经允许,请勿转载。