title: How to store values in an ArrayList dynamically
body: <p>This is a very basic or rather simple question. 
  In my code, I'm using foreach value to put values in a string variable. <strong><em>For each iteration I want to store(add one after another) that variable value in an arraylist.</em></strong> Then retrieve arraylist values by its index.</p>
  
  <p>Code I'm trying:</p>
  
  <pre><code>foreach(string abc in namestring)
  {
     string values = abc;
     ArrayList list = new ArrayList();
     list.Add(values);
  }
  </code></pre>
  
  <p>For Example: </p>
  
  <blockquote>
    <p>If 'namestring' contains values as tom, dik, harry. Then 'list' should
    contain those  values as list(0) = tom, list(1) = dik, list(2) =
    harry.</p>
  </blockquote>
  
  <p>Problem is with storing values in arraylist</p>