How to make a class non-inheritable other than sealed?
Answers were Sorted based on User's Feedback
Answer / avinash
Use static class,static class make a class non inheritable
| Is This Answer Correct ? | 13 Yes | 4 No |
Answer / jj
A static class is basically the same as a non-static class,
but there is one difference: a ... Static classes are sealed
and therefore cannot be inherited.
| Is This Answer Correct ? | 9 Yes | 1 No |
Answer / kishore.a
There are two ways:
1: Make the base class as static.
2: Declare a privete constructor in the base class.
| Is This Answer Correct ? | 8 Yes | 2 No |
Answer / nitin
1)Make the class Sealed
2)Make the class staic
3)Have private constructor (Like in single ton class)
| Is This Answer Correct ? | 5 Yes | 0 No |
Answer / chanchal rai
yes we have only one option to make none inheritable other than sealed.....we ll have to make the class Private.whenever we do use the Private keyword in the class for make it private than no any methods and class can inherit from that class
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / adhithya
use private construtor inside the class.so that it cant be
inherited
| Is This Answer Correct ? | 4 Yes | 10 No |
What is namespace give the example?
What is arraylist c#?
What is a protected class c#?
Explain the 3 types of properties in c# with an example?
What are namespaces, and how they are used?
What is a trace and asset? Explain some differences?
How many types of polymorphism are there?
What?s the difference between System.String and System.StringBuilder classes?
What is strong name in c# and how can we use it?
What are generics in c#.net?
How do I declare a pure virtual function in c#?
What is the CTS, and how does it relate to the CLS?
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)