Код: Выделить всё
{
var item = new object[reader.FieldCount];
for (int i = 0; i < reader.FieldCount; i++)
{
item[i] = reader[i];
if (i == 0)
{
item[i] = Convert.ToInt64(reader[i]);
}
else
{
item[i] = Convert.ToString(reader[i]);
}
}
var temp = new object[] { 1, "Test", "test" };
dynamic? itemTestTemp = Activator.CreateInstance(anonType, temp);
dynamic? itemTest = Activator.CreateInstance(anonType, item);
return itemTest ?? new object();
}
Исключение, которое я получаю:
System.MissingMethodException: конструктор по типу
Код: Выделить всё
'f__AnonymousType0`3[[System.Int32, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.String, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.String, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]' not found.
Извините за плохой английский, это не мой родной язык
Подробнее здесь: https://stackoverflow.com/questions/793 ... with-param