Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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()
{
Console.WriteLine(_i);
}
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();
}
}
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.