Sealed classes and interfaces represent restricted class hierarchies that provide more control over inheritance. All direct subclasses of a sealed class are known at compile time. No other subclasses may appear after a module with the sealed class is compiled.
As we can see that all subclasses of a sealed class is known at compile time it gives us the ability to use it inside when block and the compiler is able to warn us if any branch is not handled, in exactly the same way that it does for enumerations.