title: How do I use column name as variable instead of hard-typed
body: <p>My code to access the database is..</p>
  
  <pre><code>using (MyDataContext target = DataContextFactory&lt;MyDataContext&gt;.GetDataContext())
  {
      var table_orders = from tab in target.Orders
                         select tab;
  
      var cols = table_orders.First();
  
      var colNames = (from property in cols.GetType().GetProperties()
                      select property.Name).ToList();
  
      string[] fieldvalues;
      foreach (var row in table_orders)
      {
          var i = 0;
          foreach (var col in colNames)
          {
             var fieldvalues[i] = row.______.ToString(); &lt;here I need to use 'col' variable not the hard typed property i.e., Order_Id, Order_Desc etc.
             i++;
          }
      }
  }
  </code></pre>
  
  <p>How do I accomplish it? I am trying to read the table without hard-typed column names and load each row into string array.  If there is any other way also let me know.</p>