473,378 Members | 1,309 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Dimension size error

I am getting the error:
************************************************** **************************
Array does not have that many dimensions.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.IndexOutOfRangeException: Array does not have that
many dimensions.

Source Error:
Line 100: this.Session.Add("ReportTableDataBean",rtDataBean) ;
Line 101:
Line 102: lblCheckHistoryResults.Text +=
rtDataBean.dataTable.GetUpperBound(0).ToString() +
Line 103: rtDataBean.dataTable.GetUpperBound(1).ToString();
Line 104:
************************************************** **************************

If I just use "rtDataBean.dataTable.GetUpperBound(0).ToStrin g() ", it works
fine and displayes the number correctly. As soon as I added the
"rtDataBean.dataTable.GetUpperBound(1).ToStrin g() ", I got the error.

This is a 2D array, here is the defininition from the code:

public string[][] dataTable;

How do I get the size of the 2nd Dimension (which is 5 at this point)?

Thanks,

Tom
Nov 17 '05 #1
2 2679
tshad <ts**********@ftsolutions.com> wrote:
I am getting the error:
************************************************** **************************
Array does not have that many dimensions.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.IndexOutOfRangeException: Array does not have that
many dimensions.

Source Error:
Line 100: this.Session.Add("ReportTableDataBean",rtDataBean) ;
Line 101:
Line 102: lblCheckHistoryResults.Text +=
rtDataBean.dataTable.GetUpperBound(0).ToString() +
Line 103: rtDataBean.dataTable.GetUpperBound(1).ToString();
Line 104:
************************************************** **************************

If I just use "rtDataBean.dataTable.GetUpperBound(0).ToStrin g() ", it works
fine and displayes the number correctly. As soon as I added the
"rtDataBean.dataTable.GetUpperBound(1).ToStrin g() ", I got the error.

This is a 2D array, here is the defininition from the code:

public string[][] dataTable;

How do I get the size of the 2nd Dimension (which is 5 at this point)?


You don't actually have a multi-dimensional array there - you have an
array of arrays of strings.

Use dataTable.Length to find out how many string arrays you actually
have, then dataTable[i].Length to find out how large the array with
index i is.

If you actually want a rectangular array, use

public string[,] dataTable;

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #2
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
tshad <ts**********@ftsolutions.com> wrote:
I am getting the error:
************************************************** **************************
Array does not have that many dimensions.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.IndexOutOfRangeException: Array does not have
that
many dimensions.

Source Error:
Line 100: this.Session.Add("ReportTableDataBean",rtDataBean) ;
Line 101:
Line 102: lblCheckHistoryResults.Text +=
rtDataBean.dataTable.GetUpperBound(0).ToString() +
Line 103: rtDataBean.dataTable.GetUpperBound(1).ToString();
Line 104:
************************************************** **************************

If I just use "rtDataBean.dataTable.GetUpperBound(0).ToStrin g() ", it
works
fine and displayes the number correctly. As soon as I added the
"rtDataBean.dataTable.GetUpperBound(1).ToStrin g() ", I got the error.

This is a 2D array, here is the defininition from the code:

public string[][] dataTable;

How do I get the size of the 2nd Dimension (which is 5 at this point)?
You don't actually have a multi-dimensional array there - you have an
array of arrays of strings.

Use dataTable.Length to find out how many string arrays you actually
have, then dataTable[i].Length to find out how large the array with
index i is.

If you actually want a rectangular array, use

public string[,] dataTable;


That was what I was looking for.

Thanks,

Tom
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: John Pastrovick | last post by:
Sort of sizeof but applied to a particular array dimension. Similar to ASP ubound(array,dimension)
4
by: Petre Huile | last post by:
I have been designing my site for the 800x600 res for a long time. This means that I am restricted to a dimension of around 750-760 in width, since I'd like people who have a 800x600 laptop, let's...
4
by: Michael Kirchner | last post by:
Hi everybody The output of my multiple dimension array is quite confusing. Im declaring an array, store some values in it and then I save the array in a session variable. On an other page I...
9
by: James | last post by:
Hi, I am new to C++. I want to directly create a dynamic two-dimension double array, i.e. double pp. I found the "new" is only for one-dimension array, i.e. double *p = new p. How to "new" a...
6
by: Adam Hartshorne | last post by:
The input to a function of a 3rd party library I want to use requires a double**, which is a multi-dimension array of doubles. I have looked on the net etc and seen several ways of supposedly...
0
by: thefirstwml | last post by:
I am planning to load large XML files into relational tables using the dxxShredXML stored procedure. There is a major limitation on the size of the files, and I read on this group that this can be...
15
by: MackS | last post by:
The system I am working on supports a subset of C99, among which "standard-compliant VLAs". I've already learnt that VLAs can't have global scope. My question is whether I can safely declare a...
4
by: Bill Sun | last post by:
Hi, All I have a conventional question, How to create a 3 dimension array by C language. I see some declare like this: int *** array; int value; array = create3Darray(m,n,l);
9
by: dennis.sam | last post by:
Hi, Is there away to define a multi-dimensional array with respect to the number of dimensions the array has? For example, given a user spec of "a b c d", I want to create a 4 dimensional array...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.