The <Country> list becomes Country [] via the web service

I have a web service that, when called, returns a Result object containing the list is polymorphic. However, when I add a link in my client application, the public field becomes an array of the country in the client application. How to change a field in a client application to List?

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

and this is a public property

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


Accepted answer from Mehmet Aras:

Right-click the service link and select "Configure Link." Under Collection Type, select System.Collection.Generic.List. Update the service link and that should be fine.

Thanks to Matt Hamilton for suggesting creating a new list from an array.

+3
2

VS2008, , - . .

+8

, . , - , List<T> .NET, .

, :

var countries = new List<Country>(result.theResult);
+9

Source: https://habr.com/ru/post/1707850/


All Articles