ASP.NET: How To Convert An ArrayList To A String Array
Here’s a quick helper post for those looking to convert an ArrayList into a String array. I ran into this problem because I code in VB.NET and the C# code is different.
In VB:
'if you have an ArrayList named data Dim str() As String = data.ToArray(GetType(String))
In C#:
//if you have an ArrayList named "data" string[] strings = (string[])data.ToArray(typeof(string));
Hope this helps!
RSS Feed
Thanks for this! You just solved something I was struggling with! I was having this problem and came to this post via google.
Glad I could help
Thanks for the comment, Keith
Thanks for the C# code. After googling and trying a couple sites, I came across to this forum. The code works great!
thank u for the code. it helps me.
thanks again…..
nice day everyday
Hi,
Its correct.
Thanks alot.
Hi,
Thanx a lot,
It’s working