0
What is the difference between sealed and private?
3 Respuestas
+ 2
Sealed method cannot be overridden in subclass. It's useful when you have a base class A with virtual method, subclass B based on A which overrides this virtual method, and subclass C based on B which cannot override this virtual method because class B sealed it. Class C can still use it, because it should have protected or public modifier (if I remember right you cannot write private virtual methods).
You can also seal classes. Such classes cannot be used as a base class.
+ 1
If you are pertaining to their usage for methods:
sealed modifier prevents a derived class from overriding the method.
While private modifier makes methods accessible only by code in the same class or struct.
0
if method is sealed we can use it in derived class?