title: Powershell ArrayList turns a single array item back into a string
body: <p>I have a powershell script that generates an ArrayList based on the names of the folders in a given directory. So if the directory looked like the following:</p>
  
  <p>C:\Directory\One</p>
  
  <p>C:\Directory\Two</p>
  
  <p>C:\Directory\Three</p>
  
  <p>$list is an array that contains [One, Two, Three]. The line is as follows:</p>
  
  <pre><code>[System.Collections.ArrayList]$list = (Get-ChildItem C:\Directory -dir).Name
  </code></pre>
  
  <p>I can then iterate through the array of strings and do various things with them. However this stops working when there is only one folder in the directory. It seems it is no longer an ArrayList and becomes just a string. I get the following error:</p>
  
  <pre><code>Cannot convert the "Directory" value of type "System.String" to type "System.Collections.ArrayList"
  </code></pre>
  
  <p>What can be done here? Should I be using a different kind of array type?</p>