Get result in comma seperated value (CSV) using LINQ

By Mash B

Get the resultset data from datatable or any other object converted into comma seperated value.

  Ex:
  
string airCode = string.Join(",", (from p in person select p["name"].ToString()).ToArray());

// if querying datatable use below query

  string airCode = string.Join(",", (from p in datatableobj.AsEnumerable() select p["name"].ToString()).ToArray());
  // datatableobj is datatable object name

Get result in comma seperated value (CSV) using LINQ  (644 Views)