Arraylist.ToArray(type) conversion PROBLEM

  • Thread starter Thread starter Sunny
  • Start date Start date
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
 
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



.
 
Back
Top