编译错误 CS0681
编译错误 CS0681
修饰符“抽象”在字段中无效。尝试使用属性代替
您不能使字段抽象。但是,您可以拥有一个访问该字段的抽象属性。
例:以下示例生成CS 0681:
// CS0681.cs
// compile with: /target:library
abstract class C
{
abstract int num; // CS0681
}
例:尝试以下代码:
// CS0681b.cs
// compile with: /target:library
abstract class C
{
public abstract int num
{
get;
set;
}
}