Converting arraylist to string array

A

Andrew Banks

Can anyone see aproblem with this line of code

string rolelistarray = rolelist.ToArray(GetType(System.String));

I'm getting a problem with the GetType(System.String) section
 
A

Andrew Banks

c:\inetpub\wwwroot\Consolejunkies\Global.asax.cs(71): 'string' denotes a
'class' where a 'variable' was expected
 
P

Peter Rilling

GetType is a method on the Object class and does not accept any parameters.
Try using "typeof" instead of "GetType".
 
A

Andrew Banks

Peter, Rajiv,

I'm struggling to see what the solution for this could be.

Is there a way to convert a ArrayList to a string array - string[]

Your help is appreciated
 
M

Martin Dechev

string[] rolelistarray = (string[])rolelist.ToArray(typeof(string));

Greetings
Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top