Are there any big differences or advantages to using ComponentBase over Partial Class or vice versa in Blazor? I've checked the documentations from Microsoft and so far I didn't get a clear answer. Searching over the internet didn't give me much neither. If there is already a similar question, pointing me to it would be great as well.
differences or advantages to using ComponentBase over Partial Class
Those are not two different or opposite things. You can do both at the same time.
When you add a "code behind class" to for instance the Counter page:
// Counter.razor.cs
partial class Counter
{
private int currentCount = 0;
private void IncrementCount()
{
currentCount++;
}
}
you are using a default rule for partial classes. The above definition is fully equivalent to
// Counter.razor.cs
public partial class Counter : ComponentBase
{
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With