Home » Tutorials » C# » Convert DataTable to List C#

Convert DataTable to List C#

Performance improvement of cursor SQL Server
Convert DataTable to JSON in C#

Convert DataTable to List in C#

We have already explained Is Application running already in WPFExtension Method in C#Reflection Introduction c#Insert data into Database table using SQLBulkCopy class in C#as keyword C#, Import/Upload Excel file in asp.net with C#The Microsoft Jet database engine cannot open the file. It is already opened exclusively by another user,   Call method after specific time interval C#Alert from code behind asp.net,required field validator in asp.net,Difference between RegisterClientScriptBlock and RegisterStartupScript asp.netDifference between ref and out parameters.

Today we will look “How to convert DataTable to List in C#!!!”

There are 3 different ways to convert DataTable To List:

  1. Loop through
  2. LINQ
  3. Generic Method

To explain this concept using different ways, I am creating a class of Employees

and DataTable with some data

Now we will convert DataTable to List using all three methods

1. Loop Through

Lets start with first method with which we will convert DataTable to List<Employee>.

2. LINQ

Now we will look into how we could convert DataTable to List<Employee> using LINQ

3. Generic Method

Now we will convert DataTable to List<Employee> using Generic Method.

Now we will call ConvertDataTable in our main method as shown below:

Let me know your feedback and views.

You could also download Convert DataTable to List C#

About

Hello friends, My self Dhruv Sheth, I have more than 6 years of Industrial experience as a Software Developer. In my career I got chance to work with asp.net, c#,Web API, JavaScript, JQuery, WPF, WCF , Windows Application, PostScript, vb.net, GhostScript etc. So I have decided to share my knowledge with everyone and finally I have come up with TechnoThirsty.

One thought on “Convert DataTable to List C#

  1. Gaurav Modi says:

    Useful article….

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*

Time limit is exhausted. Please reload CAPTCHA.




DISCLAIMER:
The content is copyrighted to technothirsty.com and may not be reproduced on other websites without permission from the owner.You may contact us using the information below.