I am trying to convert a Data table to a generic List. I am following this post. DataTable to List<object>.
Method is
public static List<MProps> TableToList<T1>(DataTable dt)
{
if (dt == null)
{
return null;
}
List<DataRow> rows = new List<DataRow>();
foreach (DataRow row in dt.Rows)
{
rows.Add(row);
}
return TableToList<T1>(rows);
}
I keep getting two errors at "return TableToList<T1>(rows);" Saying
Error 24 Argument 1: cannot convert from 'System.Collections.Generic.List<System.Data.DataRow>' to 'System.Data.DataTable' C:\Users..\Program.cs
AND
Error 23 The best overloaded method match for 'xx.Program.TableToList<T1>(System.Data.DataTable)' has some invalid arguments C:\Users\--\Program.cs
I cant figure out what is the problem.