Skip to main content

Microsoft Silverlight

Answered Question List<T> cast errorRSS Feed

(0)

xxdevxx
xxdevxx

Member

Member

9 points

67 Posts

List<T> cast error

I have a new webservice that returns a List where T is a own defined class. When it comes back to Silverlight I can see (in debug) that e.result have all the values. But how do I cast it back to a List ??

List allCars = new List(); allCars = e.Result as List;



Error:
Cannot convert type 'SilverlightApplication1.myWebService.ArrayOfmyCar' to 'System.Collections.Generic.List' via a reference conversion, boxing conversion, unboxing conversion, wrapping conversion, or null type conversion C:\Documents and Settings\admin\My Documents\Visual Studio 2008\Projects\SPSearchSL2\SilverlightApplication1\Page.xaml.cs 64 23 SilverlightApplication1

Tony.Champion
Tony.Cha...

Member

Member

634 points

91 Posts

Answered Question

Re: List<T> cast error

You were close.

e.Result.ToList();

This should get you up and running.  Let me know if this doesn't work.

 

Tony Champion

xxdevxx
xxdevxx

Member

Member

9 points

67 Posts

Re: List<T> cast error

Ahh, thanks Tony!

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities