views:

80

answers:

1

Hi I need to pass some container of objects to WCF call

[DataContract]
class Foo
{
 // other fields omited

 [DataMember]
 public List<Foo> MyList;
}

Is it OK for serialization? If not what are my options?

+2  A: 

It's ok but the resulting type will be an array and not a list. I'm partial to using array in the contract just to make sure I don't try to use it as list someplace else.

Goran
How do you mean list will become array? Pls clarify. Thanks.
Captain Comic
You can adjust the proxy generator to emit either arrays or lists. I Think arrays are default though.
johannesg
Would changing it to IList<Foo> sort that?
MattC
You can change the defaults in you service ref. configuration. See http://dotnet.org.za/hiltong/archive/2008/05/21/using-generic-list-lt-t-gt-from-wcf-services.aspx
Goran