Skip to content

DirectCast ArrayList to Generic List

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #190287
    AhFox
    Member

    I hate to use ArrayList in my application, instead try to use Generic List or Type[] as much as possible.

    For those who are interested in one line direct cast here is an example:

    ArrayList contains String

    VB.NET cast:

    new List(of String)(DirectCast(someArrayList.toArray(GetType(String)), String()))

    or if you have your own object, do as follow change String -> your Object name.

    Hope this helps

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.