1

I have a DataTable dtTemp as follows

---------------------------------
   ID      |   Name
---------------------------------
  101      |   ABC
  102      |   PQR
---------------------------------

I just want a string which consist of all names. Like

String str="ABC,PQR"
Nithesh Narayanan
  • 11,481
  • 34
  • 98
  • 138
  • [Click here][1] hope this will help you. also [see][2] Thanks [1]: http://stackoverflow.com/questions/403445/is-there-a-vb-net-equivalent-for-cs-operator [2]: http://stackoverflow.com/questions/1245526/linq-to-sql-c-sharp-coalesce – MANISHDAN LANGA Feb 20 '12 at 05:32
  • 5
    wait, but that's not what `COALESCE()` does at all ?! http://msdn.microsoft.com/en-us/library/ms190349.aspx – tsimbalar Feb 20 '12 at 05:32

1 Answers1

3

You can use LINQ:

String.Join(",", table.AsEnumerable().Select(r => r.Name));

(or r["Name"] if it's not a typed dataset)

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964