How do you declare a method in C# that should be overridden (or overridable) by a dereived class – possibly even outside your assembly – but that should be callable only from within the actual class?
(i.e. like a private virtual function in C++)
[edit]
private virtual is exactly what I intend: ‘Here’s a way to modify my behavior, but you are still not allowed to call this function directly (because calling it requires arcane invocations that only my base class shall do)’
So to clarify it: what is the best expression for that in C#?
C# makes a stronger guarantee for ‘private’ than C++ does. In C++, you can indeed override a private virtual method. But that means that code in a base class can execute code in a derived class. Breaking the promise that the private method is truly private and can only be called by methods in the same class.
Something that doesn’t help here is that C++ doesn’t require repeating the virtual keyword. Leading up to hard to reverse-engineer mysteries like this one:
I agree there’s a possible role for private inheritance. The C# language designers said No! though.