Power5000
Power5000

Reputation: 43

Inherited base class that inherits ComponentBase in partial class gives error

I am working with a something.razor file and a code behind Something.razor.cs file. My partial class inherits from SomethingBase which itself inherits from ComponentBase.

This however gives errors

CS0115 .buildrendertree(rendertreebuilder)': no suitable method found to override in partial class CS0263 partial declarations of must not specify different base classes.

However if Something inherits directly from ComponentBase there is no issue.

First question please be gentle. I'll update with code and more detail in the morning if needed.

Upvotes: 4

Views: 1732

Answers (1)

Henk Holterman
Henk Holterman

Reputation: 273484

With a code behind file you have 2 spots where you can specify the base class.

You will always have to specify it in the .razor file because you don't want the default there:

// Something.razor
@inherits SomethingBase 

and then you have a choice in the .razor.cs file:

// Something.razor.cs (a)
partial class Something      // take base class from other part
{
} 

or

// Something.razor.cs (b)
public partial class Something : SomethingBase  // must use the same as other part
{
} 

I would use (a) .

Upvotes: 8

Related Questions