2
Answers

Converting List<> generic to array[]

Sri

Sri

16y
2.9k
1

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?

Answers (2)