title: Exception while using String.Format "Index (zero based) must be greater than or equal to zero and less than the size of the argument list."
body: <p>I have an array</p>
  
  <pre><code>ArrayList array = new ArrayList();
  array.Add("a");
  array.Add("b");
  array.Add("c");
  </code></pre>
  
  <p>and I have a string variable <strong>refFormat</strong> which has the format as below.</p>
  
  <pre><code>string refFormat = "{2} {0}";
  </code></pre>
  
  <p>I'm trying to get a string of values from the array with this format. Below is what I have written. </p>
  
  <pre><code>string newStr = String.Format(refFormat,array.ToArray());
  </code></pre>
  
  <p>I'm getting the following exception when I'm trying to do this.</p>
  
  <blockquote>
    <p>Index (zero based) must be greater than or equal to zero and less than the size of the argument list.</p>
  </blockquote>
  
  <p>I know this question sounds repeated but my doubt is how to pick the values from the array whose indexes are the ones specified in the format that <strong>2</strong> and <strong>0</strong>. Please help..</p>
  
  <p><strong>Edit</strong>: Hi sorry for putting up the wrong question. I'm using an arraylist instead of a string array I'm trying the same. I'm still getting the exception in spite of converting it to an array using ToArray(). Where am I going wrong? And also I cannot use List instead of arraylist here since the array contains data of different type. Please help me out..</p>