title: Easy way to convert Datatable to List using C#
body: <p>I am trying to convert Datatable to List using C# like this</p>
  
  <pre><code>public void GetList()
  {
  
      ds = // here my dataset;
  
      List&lt;MasterList&gt; result = new List&lt;MasterList&gt;();
      if (ds.Tables.Count &gt; 0 &amp;&amp; ds.Tables[0].Rows.Count &gt; 0)
      {
          foreach (DataRow dt in ds.Tables[0].Rows)
          {
              result.Add(new MasterList()
              {
                  Name = Convert.ToString(dt["Name"]),
                  Address = Convert.ToString(dt["Address"]),
                  City = Convert.ToString(dt["City"])
              });
  
          }
      }
  }
  </code></pre>
  
  <p>this code is working fine, but I want to know easy way to convert Datatable to List and here used foreach loop.</p>
  
  <p>so what's solution for this ?</p>