How sealed Class Improve performance
Can any one tell me how sealed class improve performance in C sharp?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Mar 15, 2011, 2:42 AM EDT
Rahul Shah19 reputationPosted Mar 15, 2011, 4:47 AM EDT
VulpesRank #55 · 29.2K reputationPosted Mar 15, 2011, 5:10 AM EDT
For example the following compiles fine:
Rahul Shah19 reputationPosted Mar 15, 2011, 9:01 AM EDT
VulpesRank #55 · 29.2K reputationPosted Mar 15, 2011, 9:20 AM EDT
Rahul Shah19 reputationPosted Mar 15, 2011, 9:22 AM EDT
VulpesRank #55 · 29.2K reputationPosted Mar 15, 2011, 9:50 AM EDT
If you're writing a library for others to use, then a more important consideration is whether it's a good idea to allow them to inherit from your classes - sometimes it isn't and you'll therefore find that some classes in the .NET framework itself are sealed.
As well as making a whole class sealed, you can also seal an 'override' method in isolation to prevent further overriding. Again this would usually be done for design rather than performance reasons.