473,657 Members | 2,776 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

adding a dimension to an array

I have an one dimensional array being created from a delimited list using
string.split. Now I'd like to take that array and add another dimension and
manually put a value in there based on the contents of the first element. I
can loop through my array no problem, but I don't see how (if?) I can add
another "column" to it. Seems like it should be simple.

Can I do this? How? TIA!

Matt
Nov 20 '05 #1
4 4740
Matt,

I don't believe you can add a dimension to an array. I would declare a new
array and use array.copy to move the contents of the old 1-dim array into
the new multi-dim array.

HTH,

Raymond Lewallen

"MattB" <so********@yah oo.com> wrote in message
news:c5******** ***@ID-86156.news.uni-berlin.de...
I have an one dimensional array being created from a delimited list using
string.split. Now I'd like to take that array and add another dimension and manually put a value in there based on the contents of the first element. I can loop through my array no problem, but I don't see how (if?) I can add
another "column" to it. Seems like it should be simple.

Can I do this? How? TIA!

Matt

Nov 20 '05 #2
* "MattB" <so********@yah oo.com> scripsit:
I have an one dimensional array being created from a delimited list using
string.split. Now I'd like to take that array and add another dimension and
manually put a value in there based on the contents of the first element. I
can loop through my array no problem, but I don't see how (if?) I can add
another "column" to it. Seems like it should be simple.


You cannot change the number of dimensions in an array, you will have to
create a new array with more dimensions and copy over data.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #3
I was actually just trying that approach. I'm having trouble using
array.copy to go from a one-demensional array to a two-dimensional array.
Anyone got a sample? Thanks!

Matt

Raymond Lewallen wrote:
Matt,

I don't believe you can add a dimension to an array. I would declare
a new array and use array.copy to move the contents of the old 1-dim
array into the new multi-dim array.

HTH,

Raymond Lewallen

"MattB" <so********@yah oo.com> wrote in message
news:c5******** ***@ID-86156.news.uni-berlin.de...
I have an one dimensional array being created from a delimited list
using string.split. Now I'd like to take that array and add another
dimension and manually put a value in there based on the contents of
the first element. I can loop through my array no problem, but I
don't see how (if?) I can add another "column" to it. Seems like it
should be simple.

Can I do this? How? TIA!

Matt


Nov 20 '05 #4
Mattb,
Array.Copy requires both arrays to have the same dimensions.

You will have to use a For loop to copy the elements.

Something like:

Dim x(9) As Integer
Dim y(9, 1) As Integer
For index As Integer = 0 To x.Length - 1
y(index, 0) = x(index)
Next

Hope this helps
Jay

"MattB" <so********@yah oo.com> wrote in message
news:c5******** ***@ID-86156.news.uni-berlin.de...
I was actually just trying that approach. I'm having trouble using
array.copy to go from a one-demensional array to a two-dimensional array.
Anyone got a sample? Thanks!

Matt

Raymond Lewallen wrote:
Matt,

I don't believe you can add a dimension to an array. I would declare
a new array and use array.copy to move the contents of the old 1-dim
array into the new multi-dim array.

HTH,

Raymond Lewallen

"MattB" <so********@yah oo.com> wrote in message
news:c5******** ***@ID-86156.news.uni-berlin.de...
I have an one dimensional array being created from a delimited list
using string.split. Now I'd like to take that array and add another
dimension and manually put a value in there based on the contents of
the first element. I can loop through my array no problem, but I
don't see how (if?) I can add another "column" to it. Seems like it
should be simple.

Can I do this? How? TIA!

Matt


Nov 20 '05 #5

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

Similar topics

4
1912
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 store the data of the session in a new multiple dimension array. All data are saved correctly in the array of the 1st page. But in the new array of the 2nd page there is only one entry. Does anybody knows
9
7756
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 two-dimension array? Is the only way to create a class? In java, I can easily create a two-dimension array by "double pp = new double". But, how to do it in C++?
6
2229
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 doing this, but I don't seem to be able to get them to work. I was wondering if anybody can tell me what I am doing wrong. int rows = 10 ; int cols = 10 ;
2
2001
by: YFS DBA | last post by:
Hello again; I've got a small invoicing database I'm trying to create. One of the tables is set up as follows: Client# Date Claim# Amount 1001 10/10/03 22.50 3003 10/11/03 18.00 1001 10/22/03 99.95
4
4328
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);
4
245
by: MattB | last post by:
I have an one dimensional array being created from a delimited list using string.split. Now I'd like to take that array and add another dimension and manually put a value in there based on the contents of the first element. I can loop through my array no problem, but I don't see how (if?) I can add another "column" to it. Seems like it should be simple. Can I do this? How? TIA! Matt
2
4560
by: Nathan Sokalski | last post by:
I have a multidimensional array declared as the following: Dim guesses(14, 5) As Integer I want to assign all values in a specific dimension to another array declared as follows:
5
7802
by: Jackson | last post by:
I have something that is stumping me. I am trying to initialize a 3 dimensional string array with the code below, but it wont compile. Can anyone explain what Im doing wrong?????????????? Im going crazy with this one! Ive tried a 2 dimensional array minus the "test3" and it works fine. public string screens; screens = new string{ {"test1","test2","test3"} };
9
3748
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 with dimensional lengths of a, b, c and d. Thanx for any help.
0
8833
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8737
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8509
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7345
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6174
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4327
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2735
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1967
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1730
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.