20-10-16, 08:07 AM
(آخر تعديل لهذه المشاركة : 20-10-16, 08:09 AM {2} بواسطة silverlight.)
ما تستخدم sorted Dictionary أسهل لك
لا تنسي اضافة الدالة التالية الي الكود
والهدف منها الحصول علي Value بواسطة المفتاح الخاص بها
PHP كود :
Dim sd As New SortedDictionary(Of Integer, String) 'انشاء قاموس
'اضافة items
sd.Add(1, "one")
sd.Add(4, "four")
sd.Add(3, "three")
sd.Add(2, "two")
sd.Add(5, "five")
sd.Add(7, "seven")
sd.Add(6, "six")
Dim five As Integer = 5
Dim fifthItem As String = GetValue(sd, five)
Dim two As Integer = 2
Dim secondItem As String = GetValue(sd, two)
sd.Remove(5)
sd.Remove(2)
Dim dic As New Dictionary(Of Integer, String)
dic.Add(five, fifthItem)
dic.Add(two, secondItem)
For Each item In sd
dic.Add(item.Key, item.Value)
Next
' عرض النتائج
For Each s As String In dic.Values
ListBox1.Items.Add(s)
Next
لا تنسي اضافة الدالة التالية الي الكود
والهدف منها الحصول علي Value بواسطة المفتاح الخاص بها
PHP كود :
Public Function GetValue(sd As SortedDictionary(Of Integer, String), key As Integer) As String
Dim result As String = Nothing
If Not sd.TryGetValue(key, result) Then
Return Nothing
End If
Return result
End Function

