Can you prevent a class from overriding?

Answer Posted / techy_unknown

Hi,

I think the question itself is illogical.

The term "overriding" is ONLY and ONLY associated with
methods/properties not to the class.

So, if the question is put a like, "How to prevent methods
not to be overriden?" then the answer is: "Make them non-
virtual."

And if the question is put a like, "How to prevent the
inheritance for a specific class?" then the answer
is, "Make the calss sealed."

I really hope that the reply makes sense here.

Is This Answer Correct ?    38 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can a struct inherit from another struct or class in c#?

515


Is everything an object c#?

491


What does ienumerable mean?

478


What is an abstract class c#?

484


Why do we need constructors?

493






Explain attributes in c#?

477


Will the following code compile?

552


Is c# a technology?

488


What is the correct way of declaring an xml namespace?

470


What is serialization in .net?

560


What are delegates?

793


What is xaml in c#?

501


What is difference between private and protected in c#?

488


Can you inherit from multiple classes in c#?

451


Why static constructor is parameterless in c#?

595