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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:19:03+00:00 2026-05-21T02:19:03+00:00

So I came across some code of mine from an old VSTO project, and

  • 0

So I came across some code of mine from an old VSTO project, and noted this little bit:

Excel.Worksheet sheet = Globals.ThisAddIn.Application.Worksheets["Unique Hits Per URL"];
        Dictionary<int, string> ids = new Dictionary<int, string>();
        object[,] cellRange = (object[,])sheet.get_Range("E:E").Cells.Value;
        for (int i = 1; i < cellRange.GetUpperBound(0); i++)
            if (cellRange[i, 1] != null)
                ids.Add(i, cellRange[i, 1].ToString());

What does specifying [,] on a datatype mean? Looking at the code it appears to function as a matrix, but honestly I thought c# matrices were handled with notation like object[ ][ ].

  • 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-05-21T02:19:04+00:00Added an answer on May 21, 2026 at 2:19 am

    object[,] refers to a rectangular array, that means it’s a grid.
    Then you have object[][] which is a jagged array, an array of array.

    The main difference is that object[,] will always have fixed dimensions, while with a jagged array (object[][]) all arrays can have different sizes.

    This is an example that clearly shows the difference in usage (both do the same):

    // Create and fill the rectangluar array
    int[,] rectangularArray = new int[10, 20];
    for (int i = 0; i < 200; i++)
        rectangularArray[i / 20, i % 20] = i;
    
    // Next line is an error:
    // int[][] jaggedArray = new int[10][20];
    int[][] jaggedArray = new int[10][]; // Initialize it
    
    // Fill the jagged array
    for (int i = 0; i < 200; i++)
    {
        if (i % 20 == 0)
            jaggedArray[i / 20] = new int[20]; // This size doesn't have to be fixed
        jaggedArray[i / 20][i % 20] = i;
    }
    
    // Print all items in the rectangular array
    foreach (int i in rectangularArray)
        Console.WriteLine(i);
    
    // Print all items in the jagged array
    // foreach (int i in jaggedArray) <-- Error
    foreach (int[] innerArray in jaggedArray)
        foreach (int i in innerArray)
            Console.WriteLine(i);
    

    EDIT:
    Warning, this code above is not real production code, it’s just the clearest way of doing it as example.
    The intensive use of divisions through / and % makes it much slower. You could better use a nested for loop.

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

Sidebar

Related Questions

While looking through some old code I came across this gem: MyObject o =
So, maybe this is a typo but I came across some old code: <td
I was going through some old code of mine and came across a hybrid
Context I came across some code, like this: if( Some_Condition ) throw 0; I
I came across some legacy code that contains a function like this: LPCTSTR returnString()
The other day, I came across this construct: static_cast<size_type>(-1) in some example C++ code,
Whilst working on some generally horrible Javascript code this morning, I came across the
I've been going through some old code, where I came across some custom defined
I came across some tests that included code like this: if (this != null)
I came across this in some example code: - (IBAction) startPlayLowNote:(id)sender { UInt32 noteNum

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.