Merge pull request #3585 from lateralusX/jlorenss/win-counter-warning
[mono.git] / mcs / errors / cs1673-2.cs
1 // CS1673: 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;
4
5 public delegate void Hello ();
6
7 struct Foo
8 {
9         public int ID;
10
11         public Foo (int id)
12         {
13                 this.ID = id;
14         }
15
16         public void Test (Foo foo)
17         {
18                 Hello hello = delegate {
19                         Hello (3);
20                 };
21                 hello ();
22         }
23
24         public void Hello (int value)
25         {
26                 if (ID != value)
27                         throw new InvalidOperationException ();
28         }
29
30         public override string ToString ()
31         {
32                 return String.Format ("Foo ({0})", ID);
33         }
34 }
35
36 class X
37 {
38         static void Main ()
39         {
40                 Foo foo = new Foo (3);
41                 foo.Test (new Foo (8));
42         }
43 }