Click here to Skip to main content
16,014,568 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

Please advice how can i add value to my 3d array.

the code which i used showing error "index outof range exception was unhandled"

arrdays(y, m, d) = (d)& "/" & (m) & "/" & (y))
Posted
Updated 26-Dec-11 2:18am
v2

One more problem in your code: using string concatenation ('&' string operator) repeatedly. Strings are immutable, so every single concatenation involves creation of a brand new string instance with copying data back and forth. You need to use string.Format for a fixed number of string operand, and mutable System.Text.StringBuilder otherwise, in cases like cycles, etc.

—SA
 
Share this answer
 
You need to look at where you declare the array, and where you assign memory space to it.
Then you need to look at the values of your y, m, d variables and check that you have allowed enough space, or they will go outside the memory you have allocated, and you will get this error message.

NOTE: 3D arrays get very big, very quickly - they expand in a cubic progression. So if your "y" is for "Year" then you may want to consider using a Dictionary, or a List instead, as if you allocate an array to hold up to 2050, you probably won't use the first 2000 entries - but they will each have 12 * 31 elements allocated...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900