title: VB : Is it possible to cast/convert from List(Of DataRow) to List(Of String)?
body: <p>I'm trying to solve a problem regarding types of list. First of all I have a stored procedure in my DB which does a select of a single column and I try to proceed it in my app in VB. By making a method function I declared a DataTable that loads through the SqlCommand(with the CloseConnection behavior). After that I publicly declared a List(Of String) which needs to be populated with the rows/items from the stored procedure that is on the way. Below is my snippet of the code:</p>
  
  <pre><code>Dim dt As New DataTable()
  
          Try
              If conn.State = ConnectionState.Open Then
                  conn.Close()
              Else
                  conn.Open()
                  Dim cmd = New SqlCommand("LoadCodes", conn)
                  cmd.CommandType = CommandType.StoredProcedure
  
                  dt.Load(cmd.ExecuteReader(CommandBehavior.CloseConnection))
                  Dim collection As New List(Of DataRow)
                  collection = dt.AsEnumerable.ToList
  
                  LPrefix = collection.Cast(Of String)()
  
              End If
          Catch ex As Exception
              MsgBox(ex.Message + vbCritical)
          End Try
  </code></pre>
  
  <p>It's <code>LPrefix = collection.Cast(Of String)()</code> where I get an exception error telling me that I can't really convert it. The old fashion way is to iterate with for/for each loop but that's not what I want for best use of performance especially if the list will have thousands of rows from a single column. So basically I want to insert those items from that DataTable to the List(Of String) without using For/For Each loop.</p>
  
  <p>Running on Visual Studio 2010 Ultimate, .NET Framework 4.0.</p>