473,406 Members | 2,707 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,406 software developers and data experts.

Help with multidimensional array please

I have created a multidimensional array as follows:

string[,] myarray = {{"TestArray1Part1", "TestArray1Part2"},{"TestArray2Part1", "TestArray2Part2"}};

Basically what I want to do is show a message box which will display the first two parts of the array (TestArray1Part1 & TestArray1Part2), then loop to show the next parts.

I am currently using a foreach statement to loop through the array but this just shows each item one by one.

Do you know how to achieve this so both parts are shown on each loop of the foreach statement?
Apr 25 '10 #1

✓ answered by tlhintoq

You aren't going to do it with a ForEach (well, you could but personally I think it's sloppy)
You're going to need to do it with counter in your loop
for (int Counter = 0)
So you can get your part1 and part2 individually and add them together.
MSDN has a tutorial on such things.
http://msdn.microsoft.com/en-us/libr...53(VS.71).aspx

4 2380
tlhintoq
3,525 Expert 2GB
Combine the two parts into one string, then show it

Expand|Select|Wrap|Line Numbers
  1. string Message = Part1 + System.Environment.NewLine + Part2;
  2. string Caption = "Iteration: " + LoopCounter.ToString();
  3. MessageBox.Show(Message, Caption";
Apr 25 '10 #2
@tlhintoq
Thank you for the help, I am just a bit lost on how to display both of the parts below:

string[,] myarray = {{"TestArray1Part1", "TestArray1Part2"},{"TestArray2Part1", "TestArray2Part2"}};

In the same foreach statement. At present I am using the following statement:

foreach (string bothparts in myarray)
{
MessageBox.Show(bothparts);
}
Apr 25 '10 #3
tlhintoq
3,525 Expert 2GB
You aren't going to do it with a ForEach (well, you could but personally I think it's sloppy)
You're going to need to do it with counter in your loop
for (int Counter = 0)
So you can get your part1 and part2 individually and add them together.
MSDN has a tutorial on such things.
http://msdn.microsoft.com/en-us/libr...53(VS.71).aspx
Apr 25 '10 #4
@tlhintoq
Perfect, I will give this a go.

Thanks for the help.
Apr 25 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Pat | last post by:
Hi, I want to use "new" to build an array test. Can you tell me how to do? Thank. Pat
9
by: Charles Banas | last post by:
i've got an interesting peice of code i'm maintaining, and i'd like to get some opinions and comments on it, hopefully so i can gain some sort of insight as to why this works. at the top of the...
1
by: Mark Smith | last post by:
I'm trying to copy data from a 1D array to a 2D array. The obvious thing doesn't work: int twoDee = new int; int oneDee = new int { 1, 2 }; Array.Copy(oneDee, 2, twoDee, 2, 2); This causes a...
3
by: Claire | last post by:
I have a multidimensional array defined as private double myArray = new double; The first column of the array contains X values, the other contains Y values I have a charting function defined as...
2
by: chris | last post by:
Hi there, I created a Multidimensional array of labels Label lblMultiArray = new Label { {Label3, LblThuTotal}, {Label4,LblFriTotal} }; Now I would like to compare the values in the array,...
4
by: trifinite | last post by:
I have a multidimensional array called 'ticket', which has 25 rows and 6 columns. I want to parse this array to a function whose purpose is to initialize the array contents of ticket (for simplicity,...
5
by: TS | last post by:
is there some code somewhere that does this? i have a jagged array that is not jagged, it has an equal number of rows and columns in each array so it should convert but want to get the code to do...
4
Jezternz
by: Jezternz | last post by:
First of all I am open to any suggestions and advice. If a javscript multidimensional array is a bad way to do this please say so. I considered XML but I wondered if this would be a bad idea as it...
2
by: ...vagrahb | last post by:
I am having accessing individual rows from a multidimensional array pass to a function as reference CODE: function Declaration int Part_Buffer(char (*buffer),int Low, int High)
9
by: Slain | last post by:
I need to convert a an array to a multidimensional one. Since I need to wrok with existing code, I need to modify a declaration which looks like this In the .h file int *x; in a initialize...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...
0
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...
0
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,...
0
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...

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.