Converting List to DataTable in C#

There is no built in method for converting list to data table in C#.
So we can implement following method for converting List to DataTable in C#.

 public DataTable ToDataTable(IList data)
        {
            PropertyDescriptorCollection props = TypeDescriptor.GetProperties(typeof(t));
            DataTable table = new DataTable();
            for (int i = 0; i < props.Count; i++)
            {
                PropertyDescriptor prop = props[i];
                table.Columns.Add(prop.Name, prop.PropertyType);
            }
            object[] values = new object[props.Count];
            foreach (t item in data)
            {
                for (int i = 0; i < values.Length; i++)
                {
                    values[i] = props[i].GetValue(item);
                }
                table.Rows.Add(values);
            }
            return table;
        }