Код: Выделить всё
Type target = Type.GetType("CPS_Service." + DocumentType);
// Create an instance of my target class
instance = Activator.CreateInstance(target);
foreach (XElement pQ in PQData.Elements())
{
try
{
// populate the member in the instance of the data class with the value from the MQ String
if (target.GetProperty(pQ.Attribute("name").Value) != null)
{
target.GetProperty(pQ.Attribute("name").Value).SetValue(instance, pqRequest[Convert.ToInt32(pQ.Attribute("pos").Value)], null);
}
}
}
PropertyInfo[] properties = target.GetProperties();
foreach (PropertyInfo property in properties)
{
DataColumn col = new DataColumn(property.Name);
col.DataType = System.Type.GetType("System.String");
col.DefaultValue = "";
dt.Columns.Add(col);
}
DataRow dr = dt.NewRow();
foreach (PropertyInfo property in properties)
{
string value = property.GetValue(instance).ToString();
dr[property.Name.ToString()] = "";
}
dt.Rows.Add(dr);
return dt; //
При заполнении строки данных dr для моей таблицы данных dt я пытаюсь получить значение из класса:
Код: Выделить всё
string value = property.GetValue(instance, null).ToString();
dr[property.Name.ToString()] = "";
Несоответствие количества параметров
Я поискал, но другие вопросы об этой ошибке не применимы...
Или мне лучше просто привести класс к списку и вернуть его?
Подробнее здесь: https://stackoverflow.com/questions/321 ... reflection
Мобильная версия