Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inherit from Attribute

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

I am trying to create an attribute from BsonRepresentationAttribute. But i am getting two compilation errors as follow

There is no argument given that corresponds to the required formal parameter 'representation' of BsonRepresentationAttribute.BsonRepresentationAttribute(BsonType)

and

Use of keyword 'base' is not valid in this context

like image 380
Beingnin Avatar asked Dec 08 '25 09:12

Beingnin


1 Answers

This isn't attribute-specific - you're just not using the right syntax to chain from one constructor to a base constructor. It should be:

public BsonObjectAttribute(BsonType representation) : base(representation)
{
}
like image 181
Jon Skeet Avatar answered Dec 10 '25 23:12

Jon Skeet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!