linux-packaging-mono/mcs/tests/test-anon-07.cs
Jo Shields a575963da9 Imported Upstream version 3.6.0
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
2014-08-13 10:39:27 +01:00

38 lines
531 B
C#

//
// Tests havign more than one anonymous method that captures the same variable
//
using System;
delegate void D ();
class X {
public static int Main ()
{
int a = 0;
D d1 = delegate {
Console.WriteLine ("First");
a = 1;
};
D d2 = delegate {
Console.WriteLine ("Second");
a = 2;
};
if (!t (a, 0))
return 1;
d1 ();
if (!t (a, 1))
return 2;
d2 ();
if (!t (a, 2))
return 3;
Console.WriteLine ("Test passes OK");
return 0;
}
static bool t (int a, int b)
{
return a == b;
}
}