Sealed Class is the class which can not be inherited.the members/methods in the sealed class can not be derived from any other class. A compile-time error occurs if a sealed class is specified as the base class of another class. By default, structs are sealed; not classes in .NET
~~~ Sealed class benchmark results (C#) ~~~
See "Benchmark" section for the code compared.
TestA.GetNumber (regular): 2.490 ns
TestB.GetNumber (sealed): 2.162 ns [faster]
So, the keyword sealed provides a way to demand that the class not to be inherited from, but it is also useful for performance optimization.
No comments:
Post a Comment