Reputation: 34367
Is it a good idea to try and return a strongly typed List of custom objects from a webservice?
Any pitfalls I should know about?
[WebMethod]
public List<CustomSerializableObject> GetList()
{
List<CustomSerializableObject> listToReturn = new List<CustomSerializableObject>();
listToReturn.Add(new CustomSerializableObject());
listToReturn.Add(new CustomSerializableObject());
listToReturn.Add(new CustomSerializableObject());
return listToReturn;
}
Upvotes: 0
Views: 620
Reputation: 2674
I don't know of any specific pitfalls to speak of other than possible support for third-parties that would want to communicate to it. You would probably be better to return an array of objects by doing listToReturn.ToArray(). You can easily fill a new list on the client side if that is what you need.
Upvotes: 1