DirectCast ArrayList to Generic List

Here you will find tutorials that will help you with programming.

DirectCast ArrayList to Generic List

Postby NVYE » Fri May 29, 2009 12:28 pm


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
Add-on Bots for educational and amusement purposes:
http://www.vipbots.com

Website:
http://www.asktechguy.com
User avatar
NVYE
imFiles Senior
imFiles Senior
 
Posts: 230
Joined: Fri Jun 10, 2005 11:29 pm

Return to Programming Tutorials

Who is online

Users browsing this forum: No registered users and 0 guests