使用英语阅读

通过


编译器错误 CS1528

应输入 ";" 或 "="(无法在声明中指定构造函数参数)

类引用的构造就像正在创建类的对象一样。 例如,尝试将变量传递给构造函数。 使用 new 运算符创建类的对象。

下面的示例生成 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();  
   }  
}