编译器错误 CS1014
更新:2007 年 11 月
错误消息
应为 get 或 set 访问器
在属性声明中发现了方法声明。在属性中只能声明 get 和 set 方法。
有关属性的更多信息,请参见 使用属性(C# 编程指南)。
示例
下面的示例生成 CS1014。
// CS1014.cs
// compile with: /target:library
class Sample
{
public int TestProperty
{
get
{
return 0;
}
int z; // CS1014 not get or set
}
}