I have been noodling around in C# and I am doing well so far but I am trying to find out how to Search an index in a multi dimensional array. I have an array which is for products made in each day. This displays the products made each day for each week by asking the user for input (using an InputBox) E.g. Week 1 Monday = 10 Bears, Wednesday = 20 Bears. Week 2 Tuesday = 30, Friday = 11, etc. I know about the IndexOf but this is for finding the index of a given value. I want to search the index and find and display the value.
The code is below:
class Day
{
private string monday;
private string tuesday;
private string wednesday;
private string thursday;
private string friday;
public string Monday
{
get { return monday; }
set { monday = value; }
}
public string Tuesday
{
get { return tuesday; }
set { tuesday = value; }
}
public string Wednesday
{
get { return wednesday; }
set { wednesday = value; }
}
public string Thursday
{
get { return thursday; }
set { thursday = value; }
}
public string Friday
{
get { return friday; }
set { friday = value; }
}
}
private void btnSelect_Click(object sender, EventArgs e)
{
Day[] week = new Day[4];
//Week[0] = new Day(); Ask users for input box value
E.g.Monday = Microsoft.VisualBasic.Interaction.InputBox("Enter the amount of products made on Monday for week 1", "Product Amount"),etc
//Prints the amounts
txtOutput.Text += "The product allocation is as follows:" + "\r\n" + "\r\n";
txtOutput.Text += " Mon Tue Wed Thu Fri \r\n";
int weeknum = 0;
//Iterates through and shows the values for each day of the week.
foreach (Day days in week)
{
weeknum++;
if (days != null)
{
txtOutput.Text += "Week " + weeknum + " " + days.Monday + " " + days.Tuesday + " " + days.Wednesday + " " + days.Thursday + " " + days.Friday + "\r\n";
}
}
}