Converting object to datatable using the C# code, it help in
many places like doing the bulk insertion of data to database. There we need to
send data in the form of table.
Suppose we have an Employee Class.
public class Employee
{
public int EmployeeId { get; set; }
public string EName { get; set; }
public int Age { get; set; }
public decimal Salary { get; set; }
}
Now instead of creating method for converting the object to
datable, we will create a generic extension method which will convert any type
of object into datatable.
public static class Utility