What are sealed classes?

A sealed class is a type used to restrict users from extending the type. A type marked CANNOT be extended by inheritance, but can be referenced by an object.

public sealed MyClass {
  // some code
}

// throws compilation error
public class SomeClass : MyClass {
}

A sealed class is a type used to restrict users from extending the type. A type marked CANNOT be extended by inheritance, but can be referenced by an object.

public sealed MyClass {
  // some code
}

// throws compilation error
public class SomeClass : MyClass {
}
Default image
Sriram Mannava

I'm a full-stack developer and a software enthusiast who likes to play around with cloud and tech stack out of curiosity.

Leave a Reply