C# – List becomes Country [] across web service

cnetweb services

I have a web service that when invoked, returns a Result object that contains a List polymorphically. However, when I add a reference in my client application, the public field becomes an array of Country in the client application. How do I change the field in the client application to List?

public Result GetCountryList()
{
    List<Country> countries = GrabCountryList();
    Result result = new Result();
    result.theResult = countries;
}

and this is the public property

public object theResult
{
     get {return _theResult; }
     set {_theResult = value;}
}


Accepted answer from Mehmet Aras:

Right click on the service reference, and select "Configure Reference". Under Collection type, select System.Collection.Generic.List. Update the service reference, and it should be good to go.

Thanks to Matt Hamilton for the suggestion to create a new list from the array.

Best Answer

If you're using VS2008, there is an advanced button on the service reference settings form that allows you control the client proxy generation. There you can select the collection type and list is among them.