Click here to Skip to main content
15,881,380 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
So im making a menu for a project and i havnt really understood this array thing.. how do i make it so it says like: " What you want to add? "
and then its like "-ITEM- Has successfully been added!" and then it does the same 4 times till you've reached up to 4 items? I have to use this Array String for this one and i really need help on this part.

note that this is on my 5th menu choice under case 5 where i want this to happen.

thanks!

What I have tried:

case 5:
                       Console.WriteLine("\t You got room for 4 more items in this compartment, what would you like to add??");

                       string[] outercompartment = new string[4];
                       outercompartment[0] = "";
                       outercompartment[1] = "";
                       outercompartment[2] = "";
                       outercompartment[3] = "";
                      foreach(string stuff in outercompartment)
                       {
                           Console.WriteLine(stuff);
                       }

                       break;
Posted
Updated 29-May-17 8:54am
v2
Comments
[no name] 15-May-17 15:17pm    
You write a for loop to get the data.
FluzzyG 15-May-17 15:20pm    
yeah like the whole program has a loop, but i need the right stuff in this praticular menuchoice?
[no name] 15-May-17 15:34pm    
How would I know? I only know what you have told us about your homework assignment. And for what you have told us, you write a for loop to get the data to put in your string array.
gggustafson 15-May-17 15:25pm    
First you must read in the four things to be done. That can be done in a loop. You could also add a test to allow fewer than four items (something like reading an empty line). I'd also suggest that you use a List < string > rather than an array. Lists are much more easily manipulated. So after you read in what the user wants to do, then you process those things. If you have further questions, reply to this comment.
FluzzyG 15-May-17 15:29pm    
yeah i've also used the List stuff, on another menuchoice, the whole project is done when i have the Array, since its a part of the assignment, but im stuck and dont realy understand how i do this, all i find is about Doing this with INT instead of String

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