Please do not reply to this email- if you want to comment on the bug, go to the URL shown below and enter your comments there.
Changed by [EMAIL PROTECTED] http://bugzilla.ximian.com/show_bug.cgi?id=76948 --- shadow/76948 2005-12-08 15:39:29.000000000 -0500 +++ shadow/76948.tmp.21032 2005-12-09 08:08:22.000000000 -0500 @@ -1,14 +1,14 @@ Bug#: 76948 Product: Mono: Compilers Version: 1.1 -OS: +OS: unknown OS Details: Status: NEW Resolution: -Severity: +Severity: Unknown Priority: Normal Component: C# AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] QAContact: [EMAIL PROTECTED] TargetMilestone: --- @@ -34,6 +34,23 @@ } } } The program should print 0, 1, 2, .., but it always prints 5. + +------- Additional Comments From [EMAIL PROTECTED] 2005-12-09 08:08 ------- +Just out of curiosity, did you test this with CSC.EXE? The current +behavior makes sense to me. + +It seems that the `i' for-loop variable will be captured & shared +across all delegate creations, since logically it's the same variable +throughout the entire loop. If you don't want a shared variable to be +passed to the delegate, you'd need to restrict its scope, e.g. + + for (int i = 0; i < 5; ++i) { + int v = i; + arr [i] = delegate {doit (v);}; + } + +At least, this is what would make sense to me, as I haven't tested +this on CSC.EXE either. _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
