public class clsBindObjectUsingDataTable { private int intCount; private List<object> objList; public void BindObject(object[] objMyObjectList, DataTable dttable) { objList = new List<object>(typeof(objMyObjectList));//to get property //of the object objList = objMyObjectList.ToList(); foreach (DataRow drRow in dttable.Rows) { intCount = drRow .ItemArray.Length; for (int i = 0; i < intCount;i++ ) { objList[0][i].Add(drRow.ItemArray[i]); ///i know this doesnt work //just wanted to give my idea } //objList.Add(drRow.ItemArray); } objMyObjectList = objList.ToArray(); } }
ObjectArray[] objectArray = DataSet.ToSpecifiedObject<ObjectArray[]>(); public static T ToSpecifiedObject<T>(this DataSet value) { byte[] buf = System.Text.UTF8Encoding.UTF8.GetBytes(value.GetXml()); MemoryStream ms = new MemoryStream(buf); XmlSerializer ser = new XmlSerializer(typeof(T)); object obj = ser.Deserialize(ms); return (T)obj; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)