Search code examples
c#wcfserializationdatacontract

WCF, containers in DataContract


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?


Solution

  • 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.