Compiler Error CS0119

'construct1_name' is a 'construct1', which is not valid in the given context.

The compiler detected an unexpected construct such as the following:

  • A class constructor is not a valid test expression in a conditional statement.

  • A class name was used instead of an instance name to refer to an array element.

  • A method identifier is used as if it were a struct or class

The following sample generates CS0119.

// CS0119.cs
using System;
public class MyClass 
{
   public static void Test() {}

   public static void Main()
   {
      Console.WriteLine(Test.x);   // CS0119
   }
}

Community Additions

ADD
Show: