**** Merged from MCS ****
[mono-project.git] / mcs / errors / cs0027-2.cs
blobd1af6ef887e4f53e9361321455afd4524da94059
1 // cs0027-2.cs: Keyword 'this' can't be used outside a constructor, a method or a property.
2 // Line: 10
4 // Attention: Here the compiler complains saying that cannot convert implicitly from 'Error0027' to 'int' but
5 // should also say that the use of keyword 'this' is out of context since it's used outside a constructor, method
6 // or property.
7 using System;
9 class Error0027 {
10 int i = this;
11 int x = 0;
13 public static void Main () {
14 Console.WriteLine ("The compiler should complain: Error CS0027 trying to use 'this' outside context.");
15 Console.WriteLine ("Trying to assign i to 'this' outside a method, property or ctr.");