Reputation: 3506
In WinRT (C#, XAML), ScrollViewer
is a sealed class, and I can't extend it, but I need to overwrite some methods (for example: ScrollToHorizontalOffset
).
Is it possible to override methods of a sealed class?
Upvotes: 8
Views: 7266
Reputation: 69
Sealed itself means that class can not be inherit and those class which can not be inherit means can not be access any property of that class in derived class.
Upvotes: 1
Reputation: 4753
As the word "sealed"
itself indicates that , it is protected from being inherited or overridden
So, No inheritance implies no Overriding.
please find this link to find more details about sealed class in detail.
Upvotes: 3
Reputation: 223322
You can't inherit from a sealed class, so no inheritance, no override.
See: override C#
The override modifier is required to extend or modify the abstract or virtual implementation of an inherited method, property, indexer, or event.
See: sealed C#
When applied to a class, the sealed modifier prevents other classes from inheriting from it.
Upvotes: 7
Reputation: 1502606
No - in order to override a method, you have to derive from it, which you can't do when the class is sealed.
Basically, you need to revisit your design to avoid this requirement...
Upvotes: 17