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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:26:30+00:00 2026-06-11T22:26:30+00:00

double[][] ServicePoint = new double[10][9]; // <– gives an error (1) double[,] ServicePoint =

  • 0
double[][] ServicePoint = new double[10][9]; // <-- gives an error (1)
double[,] ServicePoint = new double[10,9]; // <-- ok (2)

What’s their difference? (1) yields an error, what’s the reason?

And

double d = new double[9]
ServicePoint[0] = d;

using (2) will prompt an error. Why?

  • 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-11T22:26:31+00:00Added an answer on June 11, 2026 at 10:26 pm

    One is an array of arrays, and one is a 2d array. The former can be jagged, the latter is uniform.

    That is, a double[][] can validly be:

    double[][] x = new double[5][];
    
    x[0] = new double[10];
    x[1] = new double[5];
    x[2] = new double[3];
    x[3] = new double[100];
    x[4] = new double[1];
    

    Because each entry in the array is a reference to an array of double. With a jagged array, you can do an assignment to an array like you want in your second example:

    x[0] = new double[13];
    

    On the second item, because it is a uniform 2d array, you can’t assign a 1d array to a row or column, because you must index both the row and column, which gets you down to a single double:

    double[,] ServicePoint = new double[10,9];
    
    ServicePoint[0]... // <-- meaningless, a 2d array can't use just one index.
    

    UPDATE:

    To clarify based on your question, the reason your #1 had a syntax error is because you had this:

    double[][] ServicePoint = new double[10][9];
    

    And you can’t specify the second index at the time of construction. The key is that ServicePoint is not a 2d array, but an 1d array (of arrays) and thus since you are creating a 1d array (of arrays), you specify only one index:

    double[][] ServicePoint = new double[10][];
    

    Then, when you create each item in the array, each of those are also arrays, so then you can specify their dimensions (which can be different, hence the term jagged array):

    ServicePoint[0] = new double[13];
    ServicePoint[1] = new double[20];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Code double timeout_in_hours = 6.0; MyDataContext db = new MyDataContext(); using (TransactionScope tran =
Here we're using double quotes at the XSLT level; single quotes at the XPath
Using long double I get 18/19 = 0.947368421052631578... , and 947368421052631578 is the repeating
double variable = Convert.ToDouble(5/100); Will return 0.0 but i expected 0.05 What can /
Double your localStorage read performance in Chrome using indexes ls.getItem[i] not keys ls.getItem('key') Source:
double[] tab = new double[10]; I know I can gen minimum by tab.Min() .
Implement double sqrt(double x) in C++ without using std library. This is a facebook
My code is: double a = 0.6875; int[] b = new int[5]; for (int
Double-clicking a line in logcat that's part of a stacktrace will normally open the
I need to convert double value to exponential value by using xslt, and i

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.