編譯器錯誤 CS1510
更新:2007 年 11 月
錯誤訊息
ref 或 out 引數必須是可指派的變數
僅有一個變數可以在方法呼叫中,以 ref 參數方式傳遞。ref 值和傳遞指標類似。
範例
下列範例會產生 CS1510:
// CS1510.cs
public class C
{
public static int j = 0;
public static void M(ref int j)
{
j++;
}
public static void Main ()
{
M (ref 2); // CS1510, can't pass a number as a ref parameter
// try the following to resolve the error
// M (ref j);
}
}