【发布时间】:2009-12-05 16:19:48
【问题描述】:
我有这个代码:
String temp = txtForm.Rtf;
foreach (ReplaceStrut rs in replaceArray) {
temp = temp.Replace(rs.getNeedle(), rs.getReplacement());
}
if (this.InvokeRequired) {
this.Invoke(temp => txtForm.Rtf = temp);
} else {
txtForm.Rtf = temp;
}
但它不会编译。它抱怨两件事,“无法将 lambda 表达式转换为类型 'System.Delegate',因为它不是委托类型”和,“不能在此范围内声明名为 'temp' 的局部变量,因为它会给'temp',它已在'父或当前'范围中用于表示其他内容"
两个错误都在 lambda 行。我怎样才能使这项工作,我做错了什么?
【问题讨论】: