score:86
Accepted answer
you can use linq query to do that.
list<string> list = dtusers.asenumerable()
.select(r=> r.field<string>("usercode"))
.tolist();
score:5
you can try this code,
list<string> list = dt.rows.oftype<datarow>().select(dr => (string)dr["columnname"]).tolist();
Source: stackoverflow.com
Related Query
- One columned datatable to List<string>
- Convert string[] to int[] in one line of code using LINQ
- Linq code to select one item
- LINQ Source Code Available
- How to merge multiple datatables (every datatable return one row) in one row
- How can I combine this code into one or two LINQ queries?
- .NET 4 Code Contracts: "requires unproven: source != null"
- linq - how do you do a query for items in one query source that are not in another one?
- Copy a list of objects to another typed list in one line of code
- creating Linq to sqlite dbml from DbLinq source code
- Better code for avoiding one dictionary - Case Sensitivity Issue
- Select rows from one DataTable not in another
- How to select Columns using where condition from one DataTable to another in C#
- Get what exists in one DataTable but not another using LINQ
- Datatable LINQ select datarow only returning one row and how to order
- Datatable C# - How to get detail record from one table and its associated sub record from another table based on ID
- Efficiently Filtering One DataTable matching multiple columns of another DataTable in C#
- EF Code First Insert Objects with One to Many gives exception."Store update, insert, or delete statement affected an unexpected number of rows (0)."
- How can I code numerous MIN functions into one LINQ to DataSet query
- split one big datatable to two separated datatables
- Task Does Not Contain a Definition for Where If Done in One Line of Code
- Is it possible to have one LINQ in one line of code for
- C# - Copy rows from one DataTable by comparing with 2nd DataTable to 3rd DataTable
- string.contains and string.replace in one single line of code
- source code for LINQ 101 samples
- How to sort list on multiple properties in one line of code in Linq
- How do I GroupBy one column on this DataTable
- Optimized code for Insert and Update in one method with LINQ?
- Why Entity Framework Code First one to many Doesn't work properly
- How to reinsert data from one table onto itself using LINQ in code migration?
More Query from same tag
- Use Aggregate function in order by of LINQ
- Nested for loop adds to the list double the amount of times its supposed to
- Group list by month
- How to find a match in a list of LxWxT where Positions of L and W can vary
- Type Conversion error in LINQ
- How to bind top 20 records in Telerik Mvc Grid using Linq?
- Is it possible to use method in the group by method in Linq?
- How to check if items in collection contains a specific value?
- Linq to Entity Birthday Comparison
- How I can do a loop in a xml file that I get a Attributte value?
- Speeding up LINQ to EF queries to max
- LINQ selecting distinct from 4 IEnumerable lists
- Aggregate values at hourly interval using LINQ C#
- Get sample of all records in table
- Moving From LINQpad to a Proper Visual Studio Project?
- How to quickly transform a List(Of Object) into a List(Of "Object.field")?
- Compare two list Items using LINQ
- linq to xml performance
- LINQ left outer join with exclusion
- How to get the list index of the nearest number?
- Exception handling in Linq queries
- What is the best way to generate an id for new Xelement in Linq to XML?
- LINQ Scalar Operation
- Sort List<T> Property every time an item is added
- LINQ select with EF Core and cast to derived class without copying properties
- Error while insert/update records in asp.net core
- How can I evaluate an IEnumerable<T> while giving special treatment to its first and/or last element in C#?
- Import Data from Excel to SQL Server DB using LINQ to Excel
- C# Linq to XML getting the elements where value of name contains a specific string
- Reflection/Linq: Find class inside another in vb.net