當我從我的web應用程序調用WCF服務時,出現上述錯誤。無法將類型'ServiceReference1.Videos []'隱式轉換爲'System.Collections.Generic.IList <Videos>
的代碼如下
我實例化我的WCF服務:
ServiceReference1.VideosClient objService = new ServiceReference1.VideosClient();
創建我的泛型集合的新實例,所以我可以填充值
IList<Videos> videoItem = new List<Videos>();
videoItem = objService.GetVideoDetailsById(id);
txtTitle.Text = videoItem[0].Title.ToString(); ;
txtDescription.Text = videoItem[0].Description.ToString();
txtRentalPrice.Text = Convert.ToString(videoItem[0].RentalPrice);
然而,當我致電GetVideoDetailsByID
服務的方法我收到錯誤消息
無法隱式轉換類型「ServiceReference1.Videos []」到「System.Collections.Generic.IList
我已經經歷了一些類似的帖子消失,但不能似乎找到我的問題的解決方案。 我的服務參考屬性顯示我的收藏類型爲System.Collection.Generic.List
請幫忙。 非常感謝。
謝謝你的迴應。 – user2403365
謝謝你的迴應。如果我使用var vid = objService.GetVideoDetailsById(id);那麼我該如何獲取方法返回的特定項目。例如,我想獲取方法調用返回的描述 – user2403365
假設它返回一個數組,那麼其餘代碼應該按原樣工作。 – joshuahealy