Trabajar con un ArrayList

El ArrayList me resulta ser más útil que el Array regular.

Aquí hay algunos ejemplos:

Declaración de un ArrayList

VB.NET:
  1. Dim AL As ArrayList = New ArrayList

Añadir un elemento

VB.NET:
  1. AL.Add("hola")

Ordenarlo

VB.NET:
  1. AL.Sort()

Ordenarlo al revés

VB.NET:
  1. AL.Reverse()

Remover duplicados

VB.NET:
  1. Shared Function RemoverDuplicados(ByVal ElArreglo As ArrayList) As ArrayList
  2.  
  3.     Dim ret As ArrayList = New ArrayList()
  4.     Dim elemento As Object
  5.     For Each elemento In ElArreglo
  6.         If Not ret.Contains(elemento) Then
  7.             ret.Add(elemento)
  8.         End If
  9.     Next
  10.     RemoverDuplicados = ret
  11.  
  12. End Function

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.