title: Why do I get a a "Public member 'Field' on type 'String' not found." exception when converting my datatable rows to a List(Of Object) in VB.Net?
body: <p>I've got a VB.Net app which is attempting to convert the rows in a DataTable to a generic list of objects using Linq.</p>
  
  <p><strong>Here is my class (object) definition:</strong></p>
  
  <pre><code>Public Class Sample
      Public Property Field1 As String = ""
      Public Property Field2 As String = ""
  End Class
  </code></pre>
  
  <p><strong>Here is the code snippet I'm using to convert to a List(of T):</strong></p>
  
  <pre><code>Dim dt as DataTable = ' Results of some query
  Dim samples As New List(Of Sample)
  
  If dt.Rows.Count &gt; 0 Then
     samples = (From dr In dt.AsEnumerable() _
               Select New Sample() _
                  With {.Field1 = IIf(String.IsNullOrEmpty(dr.Field(Of String)(0)), "Missing Field1", dr.Field(Of String)(0)) _
                        .Field2 = IIf(String.IsNullOrEmpty(dr.Field(Of String)(1)), "Missing FIeld2", dr.Field(Of String)(1))} _
               ).ToList()
  End If
  </code></pre>
  
  <p>The code compiles fine, but I get the following exception:</p>
  
  <blockquote>
    <p>"Public member 'Field2' on type 'String' not found."</p>
  </blockquote>
  
  <p>If I only do 1 field, the statement works correctly.
  If I reverse the order of the fields within the "With" clause, I get the following exception:</p>
  
  <blockquote>
    <p>Public member 'Field1' on type 'String' not found</p>
  </blockquote>
  
  <p>.</p>
  
  <p>What am I doing wrong?
  Is there an issue with my Linq definition?</p>
  
  <p>Thanks</p>