当前位置: 首页>>代码示例>>VB.NET>>正文


VB.NET SortedList.RemoveAt方法代码示例

本文整理汇总了VB.NET中System.Collections.SortedList.RemoveAt方法的典型用法代码示例。如果您正苦于以下问题:VB.NET SortedList.RemoveAt方法的具体用法?VB.NET SortedList.RemoveAt怎么用?VB.NET SortedList.RemoveAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Collections.SortedList的用法示例。


在下文中一共展示了SortedList.RemoveAt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。

示例1: Main

' 导入命名空间
Imports System.Collections

Public Class SamplesSortedList    
    
    Public Shared Sub Main()
        
        ' Creates and initializes a new SortedList.
        Dim mySL As New SortedList()
        mySL.Add("3c", "dog")
        mySL.Add("2c", "over")
        mySL.Add("1c", "brown")
        mySL.Add("1a", "The")
        mySL.Add("1b", "quick")
        mySL.Add("3a", "the")
        mySL.Add("3b", "lazy")
        mySL.Add("2a", "fox")
        mySL.Add("2b", "jumps")
        
        ' Displays the SortedList.
        Console.WriteLine("The SortedList initially contains the following:")
        PrintKeysAndValues(mySL)
        
        ' Removes the element with the key "3b".
        mySL.Remove("3b")
        
        ' Displays the current state of the SortedList.
        Console.WriteLine("After removing ""lazy"":")
        PrintKeysAndValues(mySL)
        
        ' Removes the element at index 5.
        mySL.RemoveAt(5)
        
        ' Displays the current state of the SortedList.
        Console.WriteLine("After removing the element at index 5:")
        PrintKeysAndValues(mySL)
    End Sub
    
    
    Public Shared Sub PrintKeysAndValues(myList As SortedList)
        Console.WriteLine(ControlChars.Tab & "-KEY-" & ControlChars.Tab & _
           "-VALUE-")
        Dim i As Integer
        For i = 0 To myList.Count - 1
            Console.WriteLine(ControlChars.Tab & "{0}:" & ControlChars.Tab & _
               "{1}", myList.GetKey(i), myList.GetByIndex(i))
        Next i
        Console.WriteLine()
    End Sub
End Class
开发者ID:VB.NET开发者,项目名称:System.Collections,代码行数:50,代码来源:SortedList.RemoveAt

输出:

The SortedList initially contains the following:
-KEY-    -VALUE-
1a:    The
1b:    quick
1c:    brown
2a:    fox
2b:    jumps
2c:    over
3a:    the
3b:    lazy
3c:    dog

After removing "lazy":
-KEY-    -VALUE-
1a:    The
1b:    quick
1c:    brown
2a:    fox
2b:    jumps
2c:    over
3a:    the
3c:    dog

After removing the element at index 5:
-KEY-    -VALUE-
1a:    The
1b:    quick
1c:    brown
2a:    fox
2b:    jumps
3a:    the
3c:    dog


注:本文中的System.Collections.SortedList.RemoveAt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。