|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Convert Array of Objects to Generics List?For example, I have the following:
Dim MyObjectArray() as Object = External.Function() Is it possible to convert MyObjectArray into a Generics Collection.List? Thanks. Spam,
Have you tried: | Dim MyObjectArray() as Object = External.Function() Dim theList As New List(Of Object)(MyObjectArray)If you really want theList to be List(Of Whatever) then you need to start with an array of Whatever or convert the MyObjectArray to an array of Whatever first. | Dim MyObjectArray() as Object = External.Function() Dim MyWhateverArray() As WhateverMyWhateverArray = Array.ConvertAll(Of Object, Whatever)(MyObjectArray, AddressOf Converter) Dim theList As New List(Of Whatever)(MyWhateverArray) Private Function Converter(ByVal value As Object) As Whatever Return CType(value, Whatever) End Function Alternatively you could use a For Each to read the MyObjectArray adding the items to theList. -- Show quoteHide quoteHope this helps Jay B. Harlow [MVP - Outlook] ..NET Application Architect, Enthusiast, & Evangelist T.S. Bradley - http://www.tsbradley.net "Spam Catcher" <spamhoneypot@rogers.com> wrote in message news:Xns98021103B2928usenethoneypotrogers@127.0.0.1... | For example, I have the following: | | Dim MyObjectArray() as Object = External.Function() | | Is it possible to convert MyObjectArray into a Generics Collection.List? | | Thanks. |
Resume next in VB.NET ?
AS400 - Ado.Net from Vb.Net Slow Query Times Can I make my Form visible during a debug session? Database Connection Problem. Please Help ddl selectedindexchanged not firing on first item - I'm using a dataset to populate the ddl object reference not set to an instance of an object error Is this a bug: 2.2 - 0.4 = 1.8 but 1.2 - 0.4 = 0.8000001 ? Commenting Out Controls In HTML View multiple color + font selections in a richtextbox control webbrowser document text not adding text |
|||||||||||||||||||||||