Export (0) Print
Expand All
Expand Minimize

Compiler Error CS1528

Expected ; or = (cannot specify constructor arguments in declaration)

A reference to a class was formed as if an object to the class was being created. For example, there was an attempt to pass a variable to a constructor. Use the new operator to create an object of a class.

The following sample generates CS1528:

// CS1528.cs
using System;

public class B
   public B(int i)
      _i = i;

   public void PrintB()

   private int _i;

public class mine
   public static void Main()
      B b(3);   // CS1528, reference is not an object
      // try one of the following
      // B b;
      // or
      // B bb = new B(3);
      // bb.PrintB();
© 2014 Microsoft