本文整理汇总了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
输出:
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