Tag: 增量

Lambda参数在后面的范围内访问字段时与类字段冲突

在名称方面我的想象力很弱,所以我经常发现自己在代码中重用了标识符。 这导致我遇到这个特定的问题。 这是一些示例代码: public delegate void TestDelegate(int test); public class Test { private int test; private void method(int aaa) { TestDelegate del = test => aaa++; test++; } public static void Main() { } } 以下是编译错误(由ideone输出): prog.cs(11,3): error CS0135: `test’ conflicts with a declaration in a child block prog.cs(9,22): (Location of the symbol related to […]