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 7767243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:37:41+00:00 2026-06-01T15:37:41+00:00

I initialized an Array as Double[][] myarr = Enumerable.Repeat(new double[12], 13).ToArray(); Then in a

  • 0

I initialized an Array as

Double[][] myarr = Enumerable.Repeat(new double[12], 13).ToArray();

Then in a loop i am incrementing values like

myarr[0][0]++; 

This causes all values like myarr[1][0], myarr[2][0], myarr[3][0] ….. myarr[12][0] to increment by one.

This problem is not occurring when using a for loop (0-12) i am initializing like

myarr[i] = new double[12];

Why is this so?

  • 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-01T15:37:42+00:00Added an answer on June 1, 2026 at 3:37 pm

    Other answers have explained the problem. The solution is to create a new array on each iteration, e.g.

    double[][] myarr = Enumerable.Range(0, 13)
                                 .Select(ignored => new double[12])
                                 .ToArray();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Which is the best practice in this situation? I would like an un-initialized array
You can initialize an array like this: int [ ] arr = { 1,
I have two Arrays that are initialized as such: public static double[] arrayweight= new
Can we initialize an array of double[][][] as double[1][2][3] (this is not the correct
in C++ I want to initialize a double matrix (2-dimensional double array) like I
How do I initialize a 2D array with 0s when I declare it? double
I want to define initialized C-array in Pyrex, e.g. equivalent of: unsigned char a[8]
Why does the array a not get initialized by global variable size ? #include<stdio.h>
How do you access an array or variable declared or initialized in a nested
I have a very big constant array that is initialized at compile time. typedef

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.