منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : Concatenate List(Of T) with Func Delegate
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
الكود التالي يوضح كيف نضيف مصفوفة إلي مصفوفة أخري

PHP كود :
  Public Function ConcatenateList(Of T)(first As List(Of T), second As List(Of T)) As T()

 
       Dim concatenate As Func(Of List(Of T), List(Of T), T()) = Function(As List(Of T), As List(Of T))
 
                                                                     Dim result As T() = New T(X.Count Y.Count 1) {}
 
                                                                     For i As Integer 0 To X.Count 1
                                                                          result
(i) = X(i)
 
                                                                     Next
                                                                      For j 
As Integer 0 To Y.Count 1
                                                                          result
(X.Count j) = Y(j)
 
                                                                     Next
                                                                      Return result
                                                                  End 
Function
 
       Return concatenate(firstsecond)
 
   End Function 

الإستخدام

PHP كود :
       ' Use it as string list
        Dim l1 As List(Of String) = New List(Of String) From {"Omar", "Amr"}
        Dim l2 As List(Of String) = New List(Of String) From {"Sherief", "Ahmed", "Omar"}

        ' 
do something with the array
 
       Dim l3 As String() = ConcatenateList(Of String)(l1l2)
 
       ListBox1.Items.AddRange(l3)

 
       ' ---------------------------------------------------

        ' 
Use it as integer list
 
       Dim int1 As List(Of Integer) = New List(Of IntegerFrom {102030}
 
       Dim int2 As List(Of Integer) = New List(Of IntegerFrom {405060}
 
       Dim int3 As Integer() = ConcatenateList(Of Integer)(int1int2)

 
       ' do something with the array
        For Each i As Integer In int3
            ListBox2.Items.Add(i)
        Next