I have a web service with a few web methods. They pass around List<CustomobjectDataType> .
[WebMethod]
public List<CustomobjectDataType> webmethod1()
{
// Do something
return (List<CustomobjectDataType>)object;
}
public void WebMethod2()
{
// Do something
List<CustomobjectDataType> obj2 = WebMethod1();
}
I get a mesmatch saying that the List<> datatype cannot be converted to a
customDataType [] object.
Can anyone let me know how I could cast between or covert between List<> and array[] ?
I know ArrayList has a ToArray() but the List<> generic does not. How do I solve this?
SriPosted Jan 29, 2008, 3:13 PM
AlanPosted Jan 29, 2008, 1:58 PM
The generic List does in fact have a ToArray() method:
http://msdn2.microsoft.com/en-us/library/x303t819(VS.80).aspx
Notice that you don't need to supply a Type parameter as, of course, the List already knows what type of objects it's holding.