2010-03-02 Rodrigo Kumpera <rkumpera@novell.com>
[mcs.git] / errors / cs1673-2.cs
blobcc0b63fcedc4431d7bf15ccd8c84aeb10b1f8dab
1 // CS1673-2.cs: Anonymous methods inside structs cannot access instance members of `this'. Consider copying `this' to a local variable outside the anonymous method and using the local instead
2 // Line: 19
3 using System;
5 public delegate void Hello ();
7 struct Foo
9 public int ID;
11 public Foo (int id)
13 this.ID = id;
16 public void Test (Foo foo)
18 Hello hello = delegate {
19 Hello (3);
21 hello ();
24 public void Hello (int value)
26 if (ID != value)
27 throw new InvalidOperationException ();
30 public override string ToString ()
32 return String.Format ("Foo ({0})", ID);
36 class X
38 static void Main ()
40 Foo foo = new Foo (3);
41 foo.Test (new Foo (8));