編譯器錯誤 CS0206
更新:2007 年 11 月
錯誤訊息
無法將屬性或索引子當做 out 或 ref 參數傳遞
屬性不能當做 ref 或 out 參數傳遞。如需詳細資訊,請參閱傳遞參數 (C# 程式設計手冊)。
範例
下列範例會產生 CS0206:
// CS0206.cs
public class MyClass
{
public static int P
{
get
{
return 0;
}
set
{
}
}
public static void MyMeth(ref int i)
// public static void MyMeth(int i)
{
}
public static void Main()
{
MyMeth(ref P); // CS0206
// try the following line instead
// MyMeth(P); // CS0206
}
}