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

  • Home
  • SEARCH
  • 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 8061681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:25:09+00:00 2026-06-05T10:25:09+00:00

I have a function… private double[,] AddToArray(double[,] array, double[] dataToAdd) { // Make a

  • 0

I have a function…

private double[,] AddToArray(double[,] array, double[] dataToAdd)
{
    // Make a new row at the end of 'array' and copy values 
    // from 'dataToAdd' into the new row.
    //
    // Return the new, modified array.

}

However ‘double[,]’ isn’t dynamic and I dont know what the final size of the array will be. I can create a List from it and add the new row to the list, but then I cant seem to convert it back to a double[,]. The List.ToArray() wants to output a jagged array (double[][]). This wont work. I’m interfacing with a program developed in LabVIEW and LV refuses to accept a jagged array. LV is happy with a fixed array ([,]).

Any help?

  • 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-05T10:25:11+00:00Added an answer on June 5, 2026 at 10:25 am

    You could try this:

    private double[,] AddToArray(double[,] array, double[] dataToAdd)
    {
      var dim0 = array.GetLength(0);
      var dim1 = array.GetLength(1);
      if (dim1 != dataToAdd.Length) throw new ArgumentException();
    
      var na = new double[dim0 + 1, dim1];
      Array.Copy(array, na, array.Length);
      for (var i = 0; i < dim1; ++i) na[dim0, i] = dataToAdd[i];
    
      return na;
    }
    

    It explicitly increments the high-order dimension by one, and also verifies that the length of the low-order dimension is equal to the dataToAdd array. I have not been able to any smarter copying from dataToAdd to the 2D array than by a for loop; it is not possible to apply Array.Copy for different ranked arrays.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have function that opens up a window, and the values from the newly
i want to have function like delete file from database by using link instead
i have function like this. function load($name, $arg1, $arg2, $arg3, $arg4){ $this->$name = new
I have function below to check if specific item is directory or file: private
I have function, it receive pointer to array and pointer to function and should
I have function named: - (void) AddSortedCustomFeed :(NSMutableArray*) rssList; this function adds items(Articles) from
I have function in C that reads byte by byte from a given buffer
I have function where I read from a mysql table a set of value.
I have function that receives an array of pointers like so: void foo(int *ptrs[],
I have function that return list of strings from database. I want to show

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.