How do you keep your classes from being inherited or used as a base - ProProfs Discuss
Topics
Products
Follow Us:

How do you keep your classes from being inherited or used as a base class?



A. Declare the class as Virtual
B. Declare the class as Private
C. Declare the class as Sealed
D. Declare the class as Internal
E. None of the above

This question is part of C# test
Asked by Bstrick, Last updated: Jul 04, 2020

+ Answer
Request

1 Answer

bstrick

Bstrick

Answered Feb 20, 2018

Declare the class as Sealed

Sealed. The developer trying to derive from your class will get a message: cannot inherit from Sealed class WhateverBaseClassName.
 

Search for Google images
Select a recommended image
Upload from your computer
Search for Google images
Select a recommended image
Upload from your computer
Search for Google images
Select a recommended image
Upload from your computer

Email Sent
We have sent an email to your address "" with instructions to reset your password.