HI WELCOME TO KANSIRIS

Convert One columned datatable to List C#

Leave a Comment

 

1
2
3
4
5
6
7
8
9
10
DataTable dt = new DataTable();
List<string> list = dt.AsEnumerable()
                           .Select(r=> r.Field<string>("column name"))
                           .ToList();
 
if you don't want to mention column name try below one
 
List<string> list = dt.AsEnumerable()
                           .Select(r => r.Field<string>(0))
                           .ToList();

0 comments:

Post a Comment

Note: only a member of this blog may post a comment.