C# I'm using string arrays, and I was hoping to use a "foreach" to Display a list of them -


i believe of code correct part aside foreach statement. haven't been able test due fact program isn't compiling. i'd appreciate , help, if structure needs change somewhat.

private static void pickscreen(human myhuman)     {         var tries = 3;         bool answer = false;         string choice= "";          string[] choices = new string[6];           choices[0] = "name";         choices[1] = "age";         choices[2] = "scar type";         choices[3] = "weapon";         choices[4] = "hero status";         choices[5] = "potions";          displaynewscreenheader();          console.writeline(" screen go to?");         console.writeline();           foreach (string in choices)         {             console.writeline(" screen choice: {0}", choices[]);          }         console.writeline();         console.writeline(" or can type in " + "\"default\"" + "to not have of query screens , have character have default settings.");          while(tries > 0)         {              console.writeline(" choice: ");              choice = console.readline();                if (choice.equals("name", stringcomparison.ordinalignorecase))                  {                         displaygetheroname(myhuman);                     answer = true;                  }               else if (choice.trim().equals("age", stringcomparison.ordinalignorecase))                  {                         displaygetusersage(myhuman);                     answer = true;                  }               else if (choice.trim().equals("scar type", stringcomparison.ordinalignorecase))                 {                         displaygetscar(myhuman);                  answer = true;              }              else if (choice.trim().equals("weapon", stringcomparison.ordinalignorecase))              {                         displaygetweapon(myhuman);                  answer = true;              }               else if (choice.trim().equals("hero status", stringcomparison.ordinalignorecase))              {                         displaygetherostatus(myhuman);                     answer = true;              }              else if (choice.trim().equals("potions", stringcomparison.ordinalignorecase))              {                         displayaddbackpackitems(myhuman);                     answer = true;              }               else if (choice.trim().equals("default", stringcomparison.ordinalignorecase))               {                   console.writeline(" looks went lazy way.  anyways go conquer basements, , become ruler of stuff!");               }              else               {                  console.writeline(" dog gone it, yer missed bit tad.");                  console.writeline();                  console.writeline(" try again");                  tries -= 1;              }          }         if (answer == false)          {            displaynewscreenheader();             console.writeline(" since you're incompetent no longer have option pick query screens. go in order now.");            displaygetheroname(myhuman);            displaygetusersage(myhuman);            displaygetscar(myhuman);            displaygetweapon(myhuman);            displaygetherostatus(myhuman);            displayaddbackpackitems(myhuman);             displayreturnprompt();          }       } 

within foreach loop, variable (in case i) set each value in enumeration loop continues. you'll need change:

foreach (string in choices)         {             console.writeline(" screen choice: {0}", choices[]);          } 

to:

foreach (string in choices)         {             console.writeline(" screen choice: {0}", i);          } 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -