✅ How to call base implementation in abstract class?
I have following abstract class:
Usage:
The problem: I want to do
schemaItem.ParsecMetadata.Group = Group;
in all attributes that inherit UIControlAttribute
I know that I can call base.FillSchema( schemaItem, property, culture );
but maybe there is better way to do the same?32 Replies
unrelated but what language are you using for those code blocks?
not sure how right I am, but:
You could make a new method that the new functionality overrides, but is a
protected
keyword method?
then the FillSchema can call the new method, then you don't need to remember the base.FillSchema(...)
...? language? you know what server we're in right? 😹cpp
yeah you're gonna wanna use cs
;)
ohh, i see what you mean 😂 for the markdown language support
```csharp
<code>
```
what about this guys?
and then I override
FillSchemaDetails
not FillSchema
but call FillSchema
$code
To post C# code type the following:
```cs
// code here
```
Get an example by typing
$codegif
in chat
If your code is too long, post it to: https://paste.mod.gg/I think you can make FillSchemaDetails protected, then it forces usage on the FillSchema and wont be tempted to use FillSchemaDetails?
happy to be told otherwise 😆
calling the base ctor is the correct option here
thats what i was going to suggest
I don't understand why we don't have
public protected abstract
we do?
you cant have public + protected at the same time 😅
.net uses that approach actually
yeah they corrected it lol
ah I'm sorry
e.g. for collections, they dont let you override
.Add
, instead you override .AddItem
^ this
i was giving another option, but doing
base.
is the right thingwhat do you expect that to do
I wrote smth wrong but I just need to do following:
1. can override
2. don't let to call
this seems like a bit of a weird use of an attribute
dont let who call it?
can override => virtual
have to override => abstract
let's see:
using
FillSchema
is ok but I can call FillSchemaDetails
and it is not ok.
also can you stop using ```cpp lol
not that it matters actually
protected abstract
?mhm
dont make it public then
didn't wanna make it sound like it's that big a deal
like that - the first word from
public
to protected
ahh okay, I understand now
yeah, thanks for helping
🙌