title: How to show the dataTable in c# console?
body: <p>I have create a simple program to read from the txt file to load the data to <code>DataTable</code>. But how can I display the <code>DataTable</code> info in the console? The <code>Console.Write</code> / <code>Console.WriteLine</code> does not accept the <code>DataTable</code> as a parameter? </p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Data;
  using System.IO;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  
  namespace CompareLinuxWithWindow
  {
      class Program
      {
          static void Main(string[] args)
          {
  
              ConvertToDataTable(@"C:\Users\manchunl\Desktop\Sample.txt", 10);
  
              Console.WriteLine();
              Console.WriteLine("Press enter to exit.");
              Console.Read();
          }
  
          public static DataTable ConvertToDataTable(string filePath, int numberOfColumns)
          {
              DataTable tbl = new DataTable();
  
              for (int col = 0; col &lt; numberOfColumns; col++)
                  tbl.Columns.Add(new DataColumn("Column" + (col + 1).ToString()));
  
  
              string[] lines = System.IO.File.ReadAllLines(filePath);
  
              foreach (string line in lines)
              {
                  var cols = line.Split(',');
  
                  DataRow dr = tbl.NewRow();
                  for (int cIndex = 0; cIndex &lt; 10; cIndex++)
                  {
                      dr[cIndex] = cols[cIndex];
                  }
  
                  tbl.Rows.Add(dr);
  
              }
  
              return tbl;
          }
      }
  }
  </code></pre>