// Parse object properties and set values public static Fileline ParseProperties(Fileline line, DataRow r, List<int> index, int i, int j, ref List<int> index_) { foreach (PropertyInfo prop in line.GetType().GetProperties()) { // Check if Code or Description are empty if (r[0] == DBNull.Value || r[1] == DBNull.Value) { index.Add(j + 1); } if (r[i] != DBNull.Value) { string t = prop.PropertyType.ToString(); if (t == "System.String") { prop.SetValue(line, r[i].ToString()); } else { decimal temp = Convert.ToDecimal(r[i]); prop.SetValue(line, temp); } } i++; } return line; }