Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8244767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:57:52+00:00 2026-06-07T21:57:52+00:00

I currently have a jagged array Class[][][] which I want to serialise as a

  • 0

I currently have a jagged array Class[][][] which I want to serialise as a normal Class[] array, then convert back into a Class[][][] array after deserialization. Is it at all possible to convert between the two both ways? The dimensions are of constant sizes.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T21:57:53+00:00Added an answer on June 7, 2026 at 9:57 pm

    If you don’t mind serializing a flattened array and an array of ints, you can use the following:

    public static int[] JaggedSizes<T>(this T[][][] topArray)
    {
        List<int> rtn = new List<int>();
        rtn.Add(topArray.Length);
        for (int i = 0; i < topArray.Length; i++)
        {
            var midArray = topArray[i];
            rtn.Add(midArray.Length);
            for (int j = 0; j < midArray.Length; j++)
            {
                var botArray = midArray[j];
                rtn.Add(botArray.Length);
            }
        }
        return rtn.ToArray();
    }
    
    // Thanks @Dave Bish
    public static T[] ToFlat<T>(this T[][][] jagged)
    {
        return jagged.SelectMany(inner => 
            inner.SelectMany(innerInner => innerInner)).ToArray(); 
    }
    
    public static T[][][] FromFlatWithSizes<T>(this T[] flat, int[] sizes)
    {
        int inPtr = 0;
        int sPtr = 0;
        int topSize = sizes[sPtr++];
        T[][][] rtn = new T[topSize][][];
        for (int i = 0; i < topSize; i++)
        {
            int midSize = sizes[sPtr++];
            T[][] mid = new T[midSize][];
            rtn[i] = mid;
            for (int j = 0; j < midSize; j++)
            {
                int botSize = sizes[sPtr++];
                T[] bot = new T[botSize];
                mid[j] = bot;
                for (int k = 0; k < botSize; k++)
                {
                    bot[k] = flat[inPtr++];
                }
            }
        }
        return rtn;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function which use a 2D jagged array to save records from
I currently have an array which I populate and paste in a sheet named
I currently have a table of concentrations, which are linked to a table of
I currently have a tab bar application in the works, and have run into
i currently have a list of classes every class starts a scheduler like this:
I currently have an array of arrays. There are 10 single-item arrays in my
I currently have the following code that retrieves data from the database and then
Currently have a custom Form Element View: class Apply_View_Helper_JQueryUiFormRadio extends Zend_View_Helper_FormElement My form is
I currently have an NSOutlineView, which has an NSButton above it. When the NSOutlineView
I currently have a base class Expr and some derivatives like AddExpr , MultExpr

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.