Search code examples
c#serializationmultidimensional-arraydatacontractserializerdatacontract

DataContract + Multi-dimensional Arrays -- Any solution for this?


From MSDN:

Combining collection types (having collections of collections) is allowed. Jagged arrays are treated as collections of collections. Multidimensional arrays are not supported.

So, if you can't normally serialize a multidimensional array, how does one get around this efficiently? My thought is to have a property that flattens the array and serialize that collection and unflatten it during deserialization, but I'm not sure if that's efficient?

Anyone find a solution this before?


I should note that the reason I think flattening might work is because my dimensions are a fixed value (they are hard-coded).


Solution

  • Yes, you could flatten it or Jagged-ize it, whatever is more convenient.