I am experimenting to take datatable contents into a list. I am using following code but its not working correctly.
public List<object> ShowMessage() { List<object> obj = new List<object>(); DataTable dt = new DataTable(); dt.Columns.Add("ID"); dt.Columns.Add("Name"); dt.Rows.Add("1","AAA"); dt.Rows.Add("2", "BBB"); dt.Rows.Add("3", "CCC"); foreach (DataRow dr in dt.Rows) { obj.Add(dr); } return obj; } I am new and not sure I am doing in a right way or I need to use some thing else. Any suggestion will be highly appreciated.
Thanks.
ShowMessageis not the best name for method which returns list of some data and doesn't show anything