Will the following code compile:
 
   class Program 
   { 
      private static int i; 
      static Program(int a)
      { 
          this.i = a; 
          Console.WriteLine("In static constructor"); 
      } 
      static void Main(string[] args) { } 
  }
 
Explanation
There are two errors in the code:
1) The static constructor of the class (type constructor) must not contain parameters.
2) The keyword 'this' can not be used in static properties, methods, or static initializer field.

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Cosmo
Зареєструйся Зараз
або Підпишись на майбутні тести