当前位置: 代码迷 >> VB Dotnet >> [vb.net]Dictionary中的Orderby用法有关问题
  详细解决方案

[vb.net]Dictionary中的Orderby用法有关问题

热度:80   发布时间:2016-04-25 02:18:02.0
[vb.net]Dictionary中的Orderby用法问题
Public Class Form1

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

        Dim Dictionary2 As New Dictionary(Of Integer, String)

        Dictionary2.Add(5, 1)
        Dictionary2.Add(8, 2)
        Dictionary2.Add(4, 3)
        Dictionary2.Add(6, 4)
            

        ' 按照Key排序, 取Key
        Dictionary2.Keys.OrderBy(Function(x) x)
        '
      升序排序结果应该是键值4568的。 怎么结果还是原来的5846呢


    End Sub
End Class
------解决方案--------------------
Dictionary2.Keys.OrderBy,不会改变原有字典的排序,只是返回一个新的排序后的列表
  相关解决方案