最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - Converting an ObservableCollection to an array in Silverlight - Stack Overflow

programmeradmin1浏览0评论

I'm looking to use the HTML Bridge to send data currently in an ObservableCollection to some JavaScript. I'm assuming that this data would need to be in an array, rather than in an ObservableCollection, for it to be usable in JavaScript. Note: This assumption may be incorrect.

Silverlight doesn't seem to have the ToArray() function on its ObservableCollection class, so I was wondering if there's a nicer way to convert it into an array than iterating over the whole thing.

I'm looking to use the HTML Bridge to send data currently in an ObservableCollection to some JavaScript. I'm assuming that this data would need to be in an array, rather than in an ObservableCollection, for it to be usable in JavaScript. Note: This assumption may be incorrect.

Silverlight doesn't seem to have the ToArray() function on its ObservableCollection class, so I was wondering if there's a nicer way to convert it into an array than iterating over the whole thing.

Share Improve this question asked Oct 10, 2010 at 22:48 dlanoddlanod 9,0209 gold badges58 silver badges98 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

Silverlight 3 & 4 have the ToArray extension method on any IEnumerable<T>: http://msdn.microsoft./en-us/library/bb298736(VS.95).aspx, which an ObservableCollection<T> is.

Make sure you have System.Core referenced and a using System.Linq; at the top of your class.

Note: This should not be taking as confirmation that you have to turn it into an array to send it to Javascript. I don't know about that.

发布评论

评论列表(0)

  1. 暂无评论