The following does it in a single line:
dataTable.Rows.OfType<DataRow>()
.Select(dr => dr.Field<MyType>(columnName)).ToList();
[Edit: Add a reference to System.Data.DataSetExtensions
to your project if this does not compile]
More Related Contents:
- Convert DataTable to generic List?
- How do I use reflection to call a generic method?
- Pass An Instantiated System.Type as a Type Parameter for a Generic Class
- Convert generic List/Enumerable to DataTable?
- How to get the type of T from a member of a generic class or method
- How to read a CSV file into a .NET Datatable
- Passing arguments to C# generic new() of templated type
- What exactly is an “open generic type” in .NET? [duplicate]
- Generics in C#, using type of a variable as parameter [duplicate]
- Create instance of generic type whose constructor requires a parameter?
- A generic list of anonymous class
- Why must I provide explicitly generic parameter types While the compiler should infer the type?
- Func with out parameter
- How to select min and max values of a column in a datatable?
- How to compare 2 dataTables
- Why isn’t ArrayList marked [Obsolete]?
- Convert string to nullable type (int, double, etc…)
- How to initialize a List to a given size (as opposed to capacity)?
- Generic Type in constructor
- Collection of generic types
- Wildcard equivalent in C# generics
- DataTable equivalent in Java [duplicate]
- Best way to check if a Data Table has a null value in it
- Get Cell Value from a DataTable in C#
- Generics can’t infer second parameter? [duplicate]
- Can I have a variable number of generic parameters?
- Returning DataTables in WCF/.NET
- Which C# method overload is chosen?
- Are static members of a generic class tied to the specific instance?
- Why it is not possible to define generic indexers in .NET?