編譯器錯誤 CS1620
更新:2007 年 11 月
錯誤訊息
引數 'number' 必須用 'keyword' 關鍵字傳遞
如果您將引數傳遞至採用 ref 或 out 參數的函式,而您在呼叫時並未包含 ref 或 out 關鍵字,或是包含了錯誤的關鍵字,便會發生這個錯誤。錯誤文字會指出可使用的適當關鍵字,以及導致錯誤發生的引數。
下列範例會產生 CS1620:
// CS1620.cs
class C
{
void f(ref int i) {}
public static void Main()
{
int x = 1;
f(out x); // CS1620 – f takes a ref parameter, not an out parameter
// Try this line instead:
// f(ref x);
}
}