我正在尝试使用反射填写 pdf 表单,如下所示:
// Get the form fields for this PDF and fill them in!
var formFieldMap = GetFormFieldNames(pdfTemplate);
foreach (var fields in formFieldMap)
{
var fieldName = UppercaseFirst(fields.Key.Replace("pdf_", ""));
var proPertyValue = fosques.GetType().GetProperty(fieldName).GetValue(ques, null);
formFieldMap[fields.Key] = proPertyValue.ToString();
}
这适用于第一个属性,但在第二次迭代时它说Collection was modified; enumeration operation may not execute.
我应该创建另一个字段集合,还是可以避免这种情况?