(20-10-16, 05:26 AM)silverlight كتب :PHP كود :
Dim list As List(Of String) = New List(Of String) From {"One", "Two", "Three", "Four"}
Dim minIndex As Integer = 0
Dim maxIndex As Integer = 3
Dim value As String = list(minIndex)
list(minIndex) = list(maxIndex)
list(maxIndex) = value
' هذا الجزء من الكود لعرض النتائج فقط في ليست بوكس
For Each s As String In list
ListBox1.items.add(s)
Next
جزاك الله خير اسف لم افهم جيدآ بعد
كود :
Dim myDict As New Dictionary(Of String, String) 'انشاء قاموس
'اضافة items
myDict.Add("one", 1)
myDict.Add("four", 4)
myDict.Add("three", 3)
myDict.Add("two", 2)
myDict.Add("five", 5)
myDict.Add("seven", 7)
myDict.Add("six", 6)
Dim templist As List(Of String) = New List(Of String) 'انشاء list of string
Dim sortedDict = (From entry In myDict Order By entry.Value Ascending).ToDictionary(Function(pair) pair.Key, Function(pair) pair.Value)
'للترتيب
For Each entry As KeyValuePair(Of String, String) In sortedDict ' item loop بعد الترتيب
templist.Add(entry.Key) 'list of string الاضافة فى
ListBox1.Items.Add(entry.Key) ' الاضافة فى listbox لاظهار النتائج
Nextكيف نقل مثلآ five و two فى الاول ليك الترتيب بهذا الشكل
five
two
one
three
four
six
seven
ممكن مثلآ نقلهم الى list اخرى ثم اعادة الترتيب على هذه الشكل
لاكن فى هذه الكود
كود :
Dim list As List(Of String) = New List(Of String) From {"One", "Two", "Three", "Four"}
Dim minIndex As Integer = 0
Dim maxIndex As Integer = 3
Dim value As String = list(minIndex)
list(minIndex) = list(maxIndex)
list(maxIndex) = value
' هذا الجزء من الكود لعرض النتائج فقط في ليست بوكس
For Each s As String In list
ListBox1.Items.Add(s)
Next