Can you prevent a class from overriding?
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / nazrul
we can use sealed keyword at the time of declartion of class
thorugh which it won't inherit and won't be overide.
| Is This Answer Correct ? | 4 Yes | 6 No |
What are the extension methods in c#?
Is c# substring zero based?
Why is ienumerable used?
Is Multiple-inheritance supported by c#?
What is architecture of your poroject? how i c an say?
2 Answers Eminosoft, HCL, Phoenix Technologies,
What is written in c#?
How do you determine whether a string represents a numeric value?
If all code is written in a try block and write a catch block with Exception type Exception .In that scenario will all the exceptions catched by that catch block? or any exceptions which will not be caught?
Why c# is called c sharp?
How do I use the 'using' keyword with multiple objects?
How to declares a two-dimensional array in C#?
Is Facebook a desktop application?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)