Tengo un método de terceros que devuelve un ArrayList antiguo, y quiero convertirlo en un ArrayList mecanografiado (Of MyType).VB.NET ArrayList a List (Of T) copy/conversion mecanografiado
Dim udc As ArrayList = ThirdPartyClass.GetValues()
Dim udcT AS List(Of MyType) = ??
me han hecho un bucle simple, pero tiene que haber una mejor manera:
Dim udcT As New List(Of MyType)
While udc.GetEnumerator.MoveNext
Dim e As MyType = DirectCast(udc.GetEnumerator.Current, MyType)
udcT.Add(e)
End While
Si bien puede encontrar un código más bonito, siempre sabrá exactamente lo que está haciendo este código. Y es probablemente lo que CLR está haciendo debajo de todos modos. – Bill
@Bill Creí que el CLR podría optimizar, quizás usando variables internas a las que no tengo acceso. – vulkanino