編譯器錯誤 CS1528
更新:2007 年 11 月
錯誤訊息
必須是 ; 或 = (無法在宣告中指定建構函式引數)
類別參考的形成方式如同類別的物件建立方式。例如,嘗試傳遞變數給建構函式。請使用 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();
}
}