How should I map multidimensional to jagged arrays?

Posted by mafutrct on Stack Overflow See other posts from Stack Overflow or by mafutrct
Published on 2010-03-30T13:24:28Z Indexed on 2010/04/08 9:53 UTC
Read the original article Hit count: 551

I'd like to map Foo[,] to Foo[][] and back. There are simple solutions using loops, but isn't there something more elegant?

In my specific case, this is required in this scenario:

[DataContract]
class A
{
    // can't serialize this thingy
    private readonly Foo[,] _Foo;

    [DataMember]
    private Foo[][] SerializableFoo {
        get {
            // map here
        }
        set {
            // map here
        }
    }
}

I'm aware there are advanced solutions using IDataContractSurrogate but this seems to be overkill in my case.

© Stack Overflow or respective owner

Related posts about c#

Related posts about jagged-arrays