开发者

Can I guarantee insertion order of IEnumerables over WCF?

If I have a WCF service which accepts an IEnumerable as a parameter to a function, is the order that I look up the elements guaranteed开发者_JS百科 to be the same as they were added to the collection? (Or at least the same order they were sent across the wire?)

If not, is there a way that I can guarantee the order, such as defining it in the service contract as a List?


The serialiser will naturally serialise items in the order in which they are served up by the collection's enumerator. For a List or Array, this will always be the order in which they are added, but for anything based on a hashtable, the order is not guaranteed. To guarantee the order, use an array-based collection.


I would define it as an array, I think the IEnumerable is serialized as an array anyway.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜