Convert Object to the DataTable rows in C#

Hi,
Here I will code how to convert the objects to datatable rows in a single column. All the business objects in particular class is going to be the column data of the Datatable, in the below code  Mktdetails is my class and by creating the object am passing parameter to the objToDataTable function. Find the below code for detailed code.


//Additional Namespaces to be added

using System.Data;
using System.Reflection;


//Calling the function in Pageload


protected void Page_Load(object sender, EventArgs e)
{
  DataTable dt = new DataTable();
  Mktdetails obj = new Mktdetails();
  dt = objToDataTable(obj);
}
  

//creating the class with objects

public class Mktdetails
{
   public string Name { get; set; }
   public string Place { get; set; }
   public string Age { get; set; }
   public string Country { get; set; }
   public string Mobile { get; set; }
   public string Email { get; set; }
}

//converting the objects to DataTable

private DataTable objToDataTable(Mktdetails obj)
{
   DataTable dt = new DataTable();
   Mktdetails objmkt = new Mktdetails();
   dt.Columns.Add("Column_Name");
   foreach (PropertyInfo info in typeof(Mktdetails).GetProperties())
    {
       dt.Rows.Add(info.Name);
    }
   dt.AcceptChanges();
   return dt;
 }