C# › OOP

What does the sealed keyword do and why use it?

Intermediate

Answer

sealed stops a class being inherited or a member being further overridden. It can protect invariants and lets the JIT devirtualise calls for speed.
public sealed class Logger { }
Real-world example Sealing a security-sensitive type so no subclass can weaken its behaviour.