using System;
public class Test
{
public static void Main()
{
int variableLocal = 0;
// Captured variable:
Func<int> delegado = () => variableLocal++;
Console.WriteLine (delegado()); // 0
Console.WriteLine (delegado()); // 1
Console.WriteLine (variableLocal); // 2
}
}
dXNpbmcgU3lzdGVtOwoKcHVibGljIGNsYXNzIFRlc3QKewoJcHVibGljIHN0YXRpYyB2b2lkIE1haW4oKQoJewoJCWludCB2YXJpYWJsZUxvY2FsID0gMDsKCQkKCQkvLyBDYXB0dXJlZCB2YXJpYWJsZToKCQlGdW5jPGludD4gZGVsZWdhZG8gPSAoKSA9PiB2YXJpYWJsZUxvY2FsKys7CgkJCgkJQ29uc29sZS5Xcml0ZUxpbmUgKGRlbGVnYWRvKCkpOwkJLy8gMAoJCUNvbnNvbGUuV3JpdGVMaW5lIChkZWxlZ2FkbygpKTsJCS8vIDEKCQlDb25zb2xlLldyaXRlTGluZSAodmFyaWFibGVMb2NhbCk7CS8vIDIKCX0KfQ==