Arraylist.ToArray(type) conversion PROBLEM

S

Sunny

Hi,
I have a small function, that returns a string[], inside
the function, there is an arraylist[], being processed.
At the end of the function all the elements of the
ArrayList are copied to my returning array, using

ArrayList.ToArray(type) method.
But i am getting an error message that this conv is not
possible...

public static string[] Returner(string[] Words)
{
System.Collections.ArrayList news = new ArrayList();
for (int i=0; i<Words.Length-1; i++)
{
if (Words != "")
{news.Add(Words.ToString());}
}
return (string[])news.ToArray() //ERROR
}



Can anyone please help.
Thanks in Advance
 
S

Sunny

Thank You very much, it worked.
return (string[])news.ToArray(typeof(string));

With Regards
Syed
-----Original Message-----
Try

return (string[] news.ToArray(typeof(string)));

-vJ

Sunny said:
Hi,
I have a small function, that returns a string[], inside
the function, there is an arraylist[], being processed.
At the end of the function all the elements of the
ArrayList are copied to my returning array, using

ArrayList.ToArray(type) method.
But i am getting an error message that this conv is not
possible...

public static string[] Returner(string[] Words)
{
System.Collections.ArrayList news = new ArrayList();
for (int i=0; i<Words.Length-1; i++)
{
if (Words != "")
{news.Add(Words.ToString());}
}
return (string[])news.ToArray() //ERROR
}



Can anyone please help.
Thanks in Advance



.
 

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

Top