title: How to store user input into a List then output results - C# console program
body: <p>How do I store user input into a "List" <code>List&lt;string&gt; ItemList</code> then output whatever was entered?</p>
  
  <p>Currently, when I run the program users can enter values into the <code>varItemInput</code> and the for-loop proceeds until 10 entries have been input, but then instead of outputting the entered values, it outputs 10 empty list values. What am I doing wrong?</p>
  
  <p>I think the error is, it's not storing the users input into <code>varItemInput</code> and is just outputting the predefined empty <code>List.Add("");</code> values.</p>
  
  <p>How would I make a user populated List up to 10 entries?</p>
  
  <p>This is supposed to be like an "Inventory Program" where a user enters an item like a Hammer, then after 10 entries it displays all 10 entries on the output screen.</p>
  
  <p>I know how to do this with an array, but this particular program has to be done with a List.</p>
  
  <p>Here is my code</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  
  namespace ListProgram
  {
      class Program
      {
          static void Main(string[] args)
          {
              string varListInput = null;
              Boolean varIsValid = true;
              Int32 intTime = 3000000;
  
  
  
              while (varIsValid)
              {
                  try
                  {
                      Console.Clear(); //Clear the console program from any scren values
                      Console.WriteLine("Welcome to OTC CIS120" + "\n");
                      Console.WriteLine("ACME Co. Item Locator List Program" + "\n"); //Header     
  
  
  
                  List&lt;string&gt; ItemList = new List&lt;string&gt;();
                  ItemList.Add("");
                  ItemList.Add("");
                  ItemList.Add("");
                  ItemList.Add("");
                  ItemList.Add("");
                  ItemList.Add("");
                  ItemList.Add("");
                  ItemList.Add("");
                  ItemList.Add("");
                  ItemList.Add("");
  
                  // Reverse the output to show recent input first.
                  ItemList.Reverse();
  
                  for (int i = 0; i &lt; ItemList.Count; i++) // Continue For Loop until i is &gt; List amount.
                  {
                      Console.WriteLine(i + ": "+ "Enter Item Name To Add To Inventory"); // Asks for user input into array.
                      varListInput = Console.ReadLine(); // User inputs value into field.
  
                  }
  
                  Console.WriteLine("Items Added To Inventory Are: "); // Outputs List in reverse order. (Recent input first).
                  for (int i = 0; i &lt; ItemList.Count; i++)
                  {
                      Console.WriteLine(i + ": " + varListInput); // The entered values array output.
                  }
  
                  System.Threading.Thread.Sleep(intTime);
              }
  
              catch (Exception e)
              {
                  Console.WriteLine("The Program Has an Error: " + e.Message); // Error message if program encountered an error durring runtime.
                  varIsValid = false;
                  System.Threading.Thread.Sleep(intTime);
                  Environment.Exit(0); //Exit the program
              }
          }
      }
  }
  </code></pre>
  
  <p>}</p>