继承自属性

时间:2019-03-29 08:16:43

标签: c# .net attributes mongodb-.net-driver

public class BsonObjectAttribute: BsonRepresentationAttribute
{
    public BsonObjectAttribute(BsonType representation)
    {
        base(representation);
    }
}

我正在尝试从BsonRepresentationAttribute创建一个属性。但是我遇到了以下两个编译错误

  

没有给出与所需形式相对应的参数   BsonRepresentationAttribute.BsonRepresentationAttribute(BsonType)的参数“ representation”

  

在这种情况下,关键字“ base”的使用无效

1 个答案:

答案 0 :(得分:8)

这不是特定于属性的-您只是没有使用正确的语法从一个构造函数链接到基本构造函数。应该是:

public BsonObjectAttribute(BsonType representation) : base(representation)
{
}
相关问题