I have following example method:
namespace Postcode_webservice
{
public class Business
{
public string getBusinessDossierno(string KVKnr)
{
StringBuilder resultaat = new StringBuilder();
result = myserviceBusiness.businessGetDossierV3(KVKnr);
string city = result.results[0].CorrespondenceCity;
string postcode = result.results[0].CorrespondencePostcode;
resultaat.Append(city);
resultaat.Append(postcode);
return resultaat.ToString();
}
}
public class BusinessInfo
{
public string City { get; set; }
public string PostCode { get; set; }
public string bedrijfsNaam { get; set; }
public string adres { get; set; }
public int huisnr { get; set; }
}
}
This result in an assembly reference error. (using System.Collections.Generic has been already added)
Better depends on what you need to use it for. If you are passing this client-side to populate the listbox, then I would prefer json. However, if it is to be used server-side, I would stick to .Net objects.
As a side note, to eliminate the desire to concatenate strings to store data, I would define a type that contains both city and postal code, like this:
and then use an array (or List) of these:
And then return the list as described above. If you need to return an array, you can do this:
return myList.ToArray();which would be a return type of
MyAddressInfo[]@Thomas:
Per your comment, your method declaration should look like this:
What are the other errors that you see when you compile it like this?