1

I have a multidimensional array that represents the days of the week (Monday, Tuesday etc..) and weeks for a month (Week 1 etc..), which shows the amount of products made on each day. The array is being filled by user entry (Input box) and I am trying to figure out a way to prompt the user for a week: Week 1 etc and a day. I know of IndexOf but that gives me the index not the value in the index.

My code is:

int[,] week = new int[4, 5];

for (int Row = 0; Row < week.GetLength(0); Row++)
                {
                    if (Row == 0)
                    {
                        Week = "Week 1  ";
                    }
                    else if (Row == 1)
                    {
                        Week = "Week 2  ";
                    }
                    else if (Row == 2)
                    {
                        Week = "Week 3  ";
                    }
                    else if (Row == 3)
                    {
                        Week = "Week 4  ";
                    }
                    txtOutput.Text += "\r\n" + Week + ": ";
                    for (int Col = 0; Col < week.GetLength(1); Col++)
                    {
                        if (Col == 0)
                        {
                            Day = "Monday";
                        }
                        else if (Col == 1)
                        {
                            Day = "Tuesday";
                        }
                        else if (Col == 2)
                        {
                            Day = "Wednesday";
                        }
                        else if (Col == 3)
                        {
                            Day = "Thursday";
                        }
                        else if (Col == 4)
                        {
                            Day = "Friday";
                        }

                        string value = Microsoft.VisualBasic.Interaction.InputBox("Enter the amount of products made on " + Day + " for " + Week, "Product Amount");

                        week[Row, Col] = Int32.Parse(value);
                        txtOutput.Text += " ";
                        txtOutput.Text += value + "         ";

                    }
                }

I will probably have to make some custom method for this as there is no inbuilt method I know of but I cannot figure out what this would look like. Any help would be appreciated.

Arthur
  • 31
  • 1
  • 1
    It is not very clear what you are trying to ask, but this may help you with two-dimensional arrays: http://stackoverflow.com/a/12567404/1004522 – Ebad Masood Jan 05 '16 at 05:29
  • You know of IndexOf? IndexOf takes a value as a parameter. Why would you want to retrieve the value that is at the index of IndexOf that you called with that value? – iuliu.net Jan 05 '16 at 08:02
  • I want to implement a search function that allows me to search for a number of products that was made for a certain day in a certain week, E.g. How many products that were made Week 2 on Monday (Row 2 column 0). IndexOf allows me to search for the value (products) amount which may give that index but I want to search the index and see what value has been assigned to that position the array. – Arthur Jan 05 '16 at 09:43

1 Answers1

0

week[Row, Col] is just the answer. e.g. week[0,3], week[2,4]...

Ky Wu
  • 86
  • 1
  • 2