Jo Shields a575963da9 Imported Upstream version 3.6.0
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
2014-08-13 10:39:27 +01:00

74 lines
1.0 KiB
C#

namespace Test1
{
public delegate int TestDelegate1 ();
public interface TestItem
{
event TestDelegate1 OnUpdate;
}
public class TestItem1 : TestItem
{
private TestDelegate1 delegates1;
public TestItem1()
{
}
public int Test()
{
return delegates1 ();
}
public virtual event TestDelegate1 OnUpdate
{
add
{
System.Console.WriteLine("OnUpdate add 1");
delegates1 += value;
}
remove
{
System.Console.WriteLine("OnUpdate remove 2");
delegates1 -= value;
}
}
}
public class TestItem2 : TestItem1
{
public TestItem2()
{
}
public override event TestDelegate1 OnUpdate
{
add
{
System.Console.WriteLine("OnUpdate add 2");
base.OnUpdate += value;
}
remove
{
System.Console.WriteLine("OnUpdate remove 2");
base.OnUpdate -= value;
}
}
}
class CC
{
public static int Main()
{
TestItem1 ti = new TestItem2();
ti.OnUpdate += delegate() { return 5; };
if (ti.Test() != 5)
return 1;
return 0;
}
}
}