title: Powershell Error When Returning Collections.Generic.List[String]
body: <p>I have the following code:</p>
  
  <pre><code>[Collections.Generic.List[String]]$script:Database = New-Object Collections.Generic.List[String]
  [string]$script:DatabaseFile = "C:\NewFolder\database.csv"
  
  function RunProgram
  {
      $script:Database = getCurrentDatabase #errors after this line
  }
  function getCurrentDatabase
  {
      [string[]]$database = Get-Content -Path $script:DatabaseFile
      [Collections.Generic.List[String]]$databaseAsList = $database
      return $databaseAsList
  }
  </code></pre>
  
  <p>I get this exception after getCurrentDatabase returns:</p>
  
  <pre><code>Cannot convert the "system.object[]" value of type "system.object[]" to type "system.collections.generic.list`1[system.string]"
  </code></pre>
  
  <p>To get the code to work, I need to do this:</p>
  
  <pre><code>[Collections.Generic.List[String]]$script:Database = New-Object Collections.Generic.List[String]
  [string]$script:DatabaseFile = "C:\NewFolder\database.csv"
  
  function RunProgram
  {
      getCurrentDatabase #this works fine
  }
  function getCurrentDatabase
  {
      [string[]]$database = Get-Content -Path $script:DatabaseFile
      $script:Database = $database
  }
  </code></pre>
  
  <p>Why does the first way throw that exception, but the 2nd way doesn't?</p>
  
  <p>EDIT:
  I am using PS version 2.0 and C:\NewFolder\database.csv contains this one line:</p>
  
  <pre><code>Release Group,Email Address,Template ID,Date Viewed
  </code></pre>