I have taken up a WCF project which has the convention of returning data in Arrays as opposed to Lists. I was told that the reason for this is to improve potential interoperability with non .NET consuming applications.
Are there any good examples that illustrate that it is worth returning Arrays from a WCF service instead of Lists?
I previously worked on a project with the same implementation, and the same reasoning. I was unable to get a valid explanation from any of the project team.
I'd like to hear a justification, but until I do I don't believe this.
Both Array
and a List
serialize as a collection in XML or JSON - there is no difference, because these are interoperable and functionally null languages. Note that when you use the 'Add Service Reference...' tool in Visual Studio, you have the option of using a List
or an Array
as your collection type.
If you use a binary serialization in WCF then there will be a difference between List
and Array
, but binary serialization only works from .NET to .NET so there is no potential for interoperability issues.
Remember that web services don't return arrays. They also don't return lists. They return XML.
The XML for an array is identical to the XML for a list.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With